JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> _config.initialize(p); // since 2.5 /* First: must point to a token; if not pointing to one, advance. * This occurs before first read from JsonParser, as well as * after clearing of current token. */ JsonToken t = p.getCurrentToken(); if (t == null) { // and then we must get something... t = p.nextToken(); if (t == null) { // Throw mapping exception, since it's failure to map, not an actual parsing problem throw JsonMappingException.from(p, "No content to map due to end-of-input"); } } return t; } /** * Alternative to {@link #_initForReading(JsonParser)} used in cases where reading * of multiple values means that we may or may not want to advance the stream, * but need to do other initialization. *<p> * Base implementation only sets configured {@link FormatSchema}, if any, on parser. * * @since 2.5 */ protected void _initForMultiRead(JsonParser p) throws IOException { if (_schema != null) { p.setSchema(_schema); } _config.initialize(p); // since 2.5 } /* /********************************************************** /* Life-cycle, fluent factory methods for DeserializationFeatures /********************************************************** */ /** * Method for constructing a new reader instance that is configured * with specified feature enabled. */ public ObjectReader with(DeserializationFeature feature) { return _with(_config.with(feature)); } /** * Method for constructing a new reader instance that is configured * with specified features enabled. */ public ObjectReader with(DeserializationFeature first, DeserializationFeature... other) { return _with(_config.with(first, other)); } /** * Method for constructing a new reader instance that is configured * with specified features enabled. */ public ObjectReader withFeatures(DeserializationFeature... features) { return _with(_config.withFeatures(features)); } /** * Method for constructing a new reader instance that is configured * with specified feature disabled. */ public ObjectReader without(DeserializationFeature feature) { return _with(_config.without(feature)); }

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> DeserializationContext ctxt, JavaType rootType, JsonDeserializer<Object> deser) throws IOException { String expName = _config.getRootName(); if (expName == null) { PropertyName pname = _rootNames.findRootName(rootType, _config); expName = pname.getSimpleName(); } if (jp.getCurrentToken() != JsonToken.START_OBJECT) { throw JsonMappingException.from(jp, "Current token not START_OBJECT (needed to unwrap root name '" +expName+"'), but "+jp.getCurrentToken()); } if (jp.nextToken() != JsonToken.FIELD_NAME) { throw JsonMappingException.from(jp, "Current token not FIELD_NAME (to contain expected root name '" +expName+"'), but "+jp.getCurrentToken()); } String actualName = jp.getCurrentName(); if (!expName.equals(actualName)) { throw JsonMappingException.from(jp, "Root name '"+actualName+"' does not match expected ('" +expName+"') for type "+rootType); } // ok, then move to value itself.... jp.nextToken(); Object result; if (_valueToUpdate == null) { result = deser.deserialize(jp, ctxt); } else { deser.deserialize(jp, ctxt, _valueToUpdate); result = _valueToUpdate; } // and last, verify that we now get matching END_OBJECT if (jp.nextToken() != JsonToken.END_OBJECT) { throw JsonMappingException.from(jp, "Current token not END_OBJECT (to match wrapper object with root name '" +expName+"'), but "+jp.getCurrentToken()); } return result; } /* /********************************************************** /* Helper methods, locating deserializers etc /********************************************************** */ /** * Method called to locate deserializer for the passed root-level value. */ protected JsonDeserializer<Object> _findRootDeserializer(DeserializationContext ctxt, JavaType valueType) throws JsonMappingException { if (_rootDeserializer != null) { return _rootDeserializer; } // Sanity check: must have actual type... if (valueType == null) { if (deser == null) { try { // If not,

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> need to resolve; for which we need a temporary context as well: DeserializationContext ctxt = createDeserializationContext(null, _config); deser = ctxt.findRootValueDeserializer(valueType); if (deser != null) { _rootDeserializers.put(valueType, deser); } return deser; } catch (JsonProcessingException e) { // need to swallow? } } return deser; } /* /********************************************************** /* Internal methods, format auto-detection (since 2.1) /********************************************************** */ @SuppressWarnings("resource") protected Object _detectBindAndClose(byte[] src, int offset, int length) throws IOException { DataFormatReaders.Match match = _dataFormatReaders.findFormat(src, offset, length); if (!match.hasMatch()) { _reportUnkownFormat(_dataFormatReaders, match); } JsonParser jp = match.createParserWithMatch(); return match.getReader()._bindAndClose(jp, _valueToUpdate); } @SuppressWarnings("resource") protected Object _detectBindAndClose(DataFormatReaders.Match match, boolean forceClosing) throws IOException { if (!match.hasMatch()) { _reportUnkownFormat(_dataFormatReaders, match); } JsonParser p = match.createParserWithMatch(); // One more thing: we Own the input stream now; and while it's // not super clean way to do it, we must ensure closure so: if (forceClosing) { p.enable(JsonParser.Feature.AUTO_CLOSE_SOURCE); } // important: use matching ObjectReader (may not be 'this') return match.getReader()._bindAndClose(p, _valueToUpdate); } @SuppressWarnings("resource") protected <T> MappingIterator<T> _detectBindAndReadValues(DataFormatReaders.Match match, boolean forceClosing) throws IOException, JsonProcessingException { if (!match.hasMatch()) { _reportUnkownFormat(_dataFormatReaders, match); } JsonParser p = match.createParserWithMatch(); // One more thing: we Own the input stream now; and while it's // not super clean way to do it, we must ensure

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>package com.fasterxml.jackson.databind.ser.std; import java.io.File; import java.io.IOException; import java.lang.reflect.Type; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.databind.JavaType; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitorWrapper; /** * For now, File objects get serialized by just outputting * absolute (but not canonical) name as String value */ @SuppressWarnings("serial") public class FileSerializer extends StdScalarSerializer<File> { public FileSerializer() { super(File.class); } @Override public void serialize(File value, JsonGenerator jgen, SerializerProvider provider) throws IOException { jgen.writeString(value.getAbsolutePath()); } @Override public JsonNode getSchema(SerializerProvider provider, Type typeHint) { return createSchemaNode("string", true); } @Override public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) throws JsonMappingException { visitor.expectStringFormat(typeHint); } }

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>); if (result != null) { return result; } } catch (IllegalArgumentException iae) { cause = iae; } String msg = "not a valid textual representation"; if (cause != null) { String m2 = cause.getMessage(); if (m2 != null) { msg = msg + ", problem: "+m2; } } JsonMappingException e = ctxt.weirdStringException(text, _valueClass, msg); if (cause != null) { e.initCause(cause); } throw e; // nothing to do here, yet? We'll fail anyway } if (jp.getCurrentToken() == JsonToken.VALUE_EMBEDDED_OBJECT) { // Trivial cases; null to null, instance of type itself returned as is Object ob = jp.getEmbeddedObject(); if (ob == null) { return null; } if (_valueClass.isAssignableFrom(ob.getClass())) { return (T) ob; } return _deserializeEmbedded(ob, ctxt); } throw ctxt.mappingException(_valueClass); } protected abstract T _deserialize(String value, DeserializationContext ctxt) throws IOException; protected T _deserializeEmbedded(Object ob, DeserializationContext ctxt) throws IOException { // default impl: error out throw ctxt.mappingException("Don't know how to convert embedded Object of type "+ob.getClass().getName()+" into "+_valueClass.getName()); } protected T _deserializeFromEmptyString() throws IOException { return null; } /* /********************************************************** /* A general-purpose implementation /********************************************************** */ /** * "Chameleon" deserializer that works on simple types that are deserialized * from a simple String. * * @since 2.4 */ public static class Std extends FromStringDeserializer<Object> { private static final long serialVersionUID = 1; public final static int STD_FILE = 1; public final static int STD_URL = 2; public final static int STD_URI = 3; public final static int STD_CLASS = 4; public final static int STD_JAVA_TYPE = 5; public final static int STD_CURRENCY = 6; public final static int STD

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>package com.fasterxml.jackson.databind.exc; import com.fasterxml.jackson.core.JsonLocation; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.databind.JsonMappingException; /** * Specialized sub-class of {@link JsonMappingException} * that is used when the underlying problem appears to be that * of bad formatting of a value to deserialize. * * @since 2.1 */ public class InvalidFormatException extends JsonMappingException { private static final long serialVersionUID = 1L; // silly Eclipse, warnings /** * Underlying value that could not be deserialized into * target type, if available. */ protected final Object _value; /** * Intended target type (type-erased class) that value could not * be deserialized into, if known. */ protected final Class<?> _targetType; /* /********************************************************** /* Life-cycle /********************************************************** */ public InvalidFormatException(String msg, Object value, Class<?> targetType) { super(msg); _value = value; _targetType = targetType; } public InvalidFormatException(String msg, JsonLocation loc, Object value, Class<?> targetType) { super(msg, loc); _value = value; _targetType = targetType; } public static InvalidFormatException from(JsonParser jp, String msg, Object value, Class<?> targetType) { return new InvalidFormatException(msg, jp.getTokenLocation(), value, targetType); } /* /********************************************************** /* Additional accessors /********************************************************** */ /** * Accessor for checking source value (String, Number usually) that could not * be deserialized into target type ({@link #getTargetType}). * Note that value may not be available, depending on who throws the exception * and when. */ public Object getValue() { return _value; } /** * Accessor for checking target type of value ({@link #getValue} that failed * to deserialize. * Note that type may not be available, depending on who throws the exception * and when. */ public Class<?> getTargetType() { return _targetType; } }

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> @SuppressWarnings("unchecked") public StdDelegatingDeserializer(Converter<Object,T> converter, JavaType delegateType, JsonDeserializer<?> delegateDeserializer) { super(delegateType); _converter = converter; _delegateType = delegateType; _delegateDeserializer = (JsonDeserializer<Object>) delegateDeserializer; } /** * @since 2.5 */ protected StdDelegatingDeserializer(StdDelegatingDeserializer<T> src) { super(src); _converter = src._converter; _delegateType = src._delegateType; _delegateDeserializer = src._delegateDeserializer; } /** * Method used for creating resolved contextual instances. Must be * overridden when sub-classing. */ protected StdDelegatingDeserializer<T> withDelegate(Converter<Object,T> converter, JavaType delegateType, JsonDeserializer<?> delegateDeserializer) { if (getClass() != StdDelegatingDeserializer.class) { throw new IllegalStateException("Sub-class "+getClass().getName()+" must override 'withDelegate'"); } return new StdDelegatingDeserializer<T>(converter, delegateType, delegateDeserializer); } /* /********************************************************** /* Contextualization /********************************************************** */ @Override public void resolve(DeserializationContext ctxt) throws JsonMappingException { if (_delegateDeserializer != null && _delegateDeserializer instanceof ResolvableDeserializer) { ((ResolvableDeserializer) _delegateDeserializer).resolve(ctxt); } } @Override public JsonDeserializer<?> createContextual(DeserializationContext ctxt, BeanProperty property) throws JsonMappingException { // First: if already got serializer to delegate to, contextualize it: if (_delegateDeserializer != null) { JsonDeserializer<?> deser = ctxt.handleSecondaryContextualization(_delegateDeserializer, property, _delegateType); if (deser != _delegateDeserializer) { return withDelegate(_converter, _delegateType, deser); } return this; } // Otherwise: figure out what is the fully generic delegate type, then find deserializer JavaType delegateType = _converter.getInputType(ctxt.getTypeFactory()); return withDelegate(_converter, delegateType, ctxt.findContextualValueDeserializer(delegateType, property)); } /* /********************************************************** /* Accessors /********************************************************** */ @Override public JsonDeserializer

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>package com.fasterxml.jackson.databind.ser; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize.Inclusion; import com.fasterxml.jackson.databind.introspect.*; import com.fasterxml.jackson.databind.jsontype.TypeSerializer; import com.fasterxml.jackson.databind.util.*; /** * Helper class for {@link BeanSerializerFactory} that is used to * construct {@link BeanPropertyWriter} instances. Can be sub-classed * to change behavior. */ public class PropertyBuilder { final protected SerializationConfig _config; final protected BeanDescription _beanDesc; /** * Default inclusion mode for properties of the POJO for which * properties are collected; possibly overridden on * per-property basis. */ final protected JsonInclude.Include _defaultInclusion; final protected AnnotationIntrospector _annotationIntrospector; /** * If a property has serialization inclusion value of * {@link Inclusion#ALWAYS}, we need to know the default * value of the bean, to know if property value equals default * one. */ protected Object _defaultBean; public PropertyBuilder(SerializationConfig config, BeanDescription beanDesc) { _config = config; _beanDesc = beanDesc; _defaultInclusion = beanDesc.findSerializationInclusion(config.getSerializationInclusion()); _annotationIntrospector = _config.getAnnotationIntrospector(); } /* /********************************************************** /* Public API /********************************************************** */ public Annotations getClassAnnotations() { return _beanDesc.getClassAnnotations(); } /** * @param contentTypeSer Optional explicit type information serializer * to use for contained values (only used for properties that are * of container type) */ protected BeanPropertyWriter buildWriter(SerializerProvider prov, BeanPropertyDefinition propDef, JavaType declaredType, JsonSerializer<?> ser, TypeSerializer typeSer, TypeSerializer contentTypeSer, AnnotatedMember am, boolean defaultUseStaticTyping) throws JsonMappingException { // do we have annotation that forces type to use (to declared type or its super type)? JavaType serializationType

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>(); // Issue#381 if (curr == JsonToken.START_ARRAY && ctxt.isEnabled(DeserializationFeature.UNWRAP_SINGLE_VALUE_ARRAYS)) { jp.nextToken(); final Enum<?> parsed = deserialize(jp, ctxt); curr = jp.nextToken(); if (curr != JsonToken.END_ARRAY) { throw ctxt.wrongTokenException(jp, JsonToken.END_ARRAY, "Attempted to unwrap single value array for single '" + _resolver.getEnumClass().getName() + "' value but there was more than a single value in the array"); } return parsed; } throw ctxt.mappingException(_resolver.getEnumClass()); } protected void _checkFailOnNumber(DeserializationContext ctxt) throws IOException { if (ctxt.isEnabled(DeserializationFeature.FAIL_ON_NUMBERS_FOR_ENUMS)) { throw ctxt.mappingException("Not allowed to deserialize Enum value out of JSON number (disable DeserializationConfig.DeserializationFeature.FAIL_ON_NUMBERS_FOR_ENUMS to allow)"); } } /* /********************************************************** /* Additional helper classes /********************************************************** */ /** * Deserializer that uses a single-String static factory method * for locating Enum values by String id. */ protected static class FactoryBasedDeserializer extends StdDeserializer<Object> implements ContextualDeserializer { private static final long serialVersionUID = 1; // Marker type; null if String expected; otherwise numeric wrapper protected final Class<?> _inputType; protected final Method _factory; protected final JsonDeserializer<?> _deser; public FactoryBasedDeserializer(Class<?> cls, AnnotatedMethod f, Class<?> inputType) { super(cls); _factory = f.getAnnotated(); _inputType = inputType; _deser = null; } protected FactoryBasedDeserializer(FactoryBasedDeserializer base, JsonDeserializer<?> deser) { super(base._valueClass); _inputType = base._inputType; _factory = base._factory; _deser = deser; } @Override public JsonDeserializer<?> createContextual(DeserializationContext ctxt, BeanProperty property) throws JsonMappingException { if ((_deser == null) && (_inputType != String.class)) { return new FactoryBased

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>package com.fasterxml.jackson.databind.util; import java.io.*; import java.util.concurrent.ConcurrentHashMap; /** * Helper for simple bounded maps used for reusing lookup values. *<p> * Note that serialization behavior is such that contents are NOT serialized, * on assumption that all use cases are for caching where persistence * does not make sense. The only thing serialized is the cache size of Map. *<p> * NOTE: since version 2.4.2, this is <b>NOT</b> an LRU-based at all; reason * being that it is not possible to use JDK components that do LRU _AND_ perform * well wrt synchronization on multi-core systems. So we choose efficient synchronization * over potentially more efficient handling of entries. *<p> * And yes, there are efficient LRU implementations such as * <a href="https://code.google.com/p/concurrentlinkedhashmap/">concurrentlinkedhashmap</a>; * but at this point we really try to keep external deps to minimum. But perhaps * a shaded variant may be used one day. */ public class LRUMap<K,V> implements java.io.Serializable { private static final long serialVersionUID = 1L; protected final transient int _maxEntries; protected final transient ConcurrentHashMap<K,V> _map; public LRUMap(int initialEntries, int maxEntries) { // We'll use concurrency level of 4, seems reasonable _map = new ConcurrentHashMap<K,V>(initialEntries, 0.8f, 4); _maxEntries = maxEntries; } public V put(K key, V value) { if (_map.size() >= _maxEntries) { // double-locking, yes, but safe here; trying to avoid "clear storms" synchronized (this) { if (_map.size() >= _maxEntries) { clear(); } } } return _map.put(key, value); } /** * @since 2.5 */ public V putIfAbsent(K key, V value) { // not 100% optimal semantically, but better from correctness (never exceeds // defined

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>package com.fasterxml.jackson.databind.exc; import java.util.Collection; import java.util.Collections; import java.util.Iterator; import com.fasterxml.jackson.core.JsonLocation; import com.fasterxml.jackson.databind.JsonMappingException; /** * Base class for {@link JsonMappingException}s that are specifically related * to problems related to binding an individual property. * * @since 2.3 */ @SuppressWarnings("serial") public abstract class PropertyBindingException extends JsonMappingException { /** * Class that does not contain mapping for the unrecognized property. */ protected final Class<?> _referringClass; /** *<p> * Note: redundant information since it is also included in the * reference path. */ protected final String _propertyName; /** * Set of ids of properties that are known for the type, if this * can be statically determined. */ protected final Collection<Object> _propertyIds; /** * Lazily constructed description of known properties, used for * constructing actual message if and as needed. */ protected transient String _propertiesAsString; protected PropertyBindingException(String msg, JsonLocation loc, Class<?> referringClass, String propName, Collection<Object> propertyIds) { super(msg, loc); _referringClass = referringClass; _propertyName = propName; _propertyIds = propertyIds; } /* /********************************************************** /* Overrides /********************************************************** */ /** * Somewhat arbitrary limit, but let's try not to create uselessly * huge error messages */ private final static int MAX_DESC_LENGTH = 1000; @Override public String getMessageSuffix() { String suffix = _propertiesAsString; if (suffix == null && _propertyIds != null) { StringBuilder sb = new StringBuilder(100); int len = _propertyIds.size(); if (len == 1) { sb.append(" (one known property: \""); sb.append(String.valueOf(_propertyIds.iterator().next())); sb.append('"'); } else { sb.append(" (").append(len).append(" known properties: "); Iterator<Object> it = _property

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>values = v; _serializeAsIndex = serializeAsIndex; } /** * Factory method used by {@link com.fasterxml.jackson.databind.ser.BasicSerializerFactory} * for constructing serializer instance of Enum types. * * @since 2.1 */ @SuppressWarnings("unchecked") public static EnumSerializer construct(Class<?> enumClass, SerializationConfig config, BeanDescription beanDesc, JsonFormat.Value format) { // [JACKSON-212]: If toString() is to be used instead, leave EnumValues null EnumValues v = EnumValues.construct(config, (Class<Enum<?>>) enumClass); Boolean serializeAsIndex = _isShapeWrittenUsingIndex(enumClass, format, true); return new EnumSerializer(v, serializeAsIndex); } /** * To support some level of per-property configuration, we will need * to make things contextual. We are limited to "textual vs index" * choice here, however. */ @Override public JsonSerializer<?> createContextual(SerializerProvider prov, BeanProperty property) throws JsonMappingException { if (property != null) { JsonFormat.Value format = prov.getAnnotationIntrospector().findFormat((Annotated) property.getMember()); if (format != null) { Boolean serializeAsIndex = _isShapeWrittenUsingIndex(property.getType().getRawClass(), format, false); if (serializeAsIndex != _serializeAsIndex) { return new EnumSerializer(_values, serializeAsIndex); } } } return this; } /* /********************************************************** /* Extended API for Jackson databind core /********************************************************** */ public EnumValues getEnumValues() { return _values; } /* /********************************************************** /* Actual serialization /********************************************************** */ @Override public final void serialize(Enum<?> en, JsonGenerator jgen, SerializerProvider provider) throws IOException { // [JACKSON-684]: serialize as index? if (_serializeAsIndex(provider)) { jgen.writeNumber(en.ordinal()); return; } jgen.writeString(_values.serializedValueFor(en)); } @Override public JsonNode getSchema(SerializerProvider provider, Type typeHint) { // [JACKSON-

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>684]: serialize as index? if (_serializeAsIndex(provider)) { return createSchemaNode("integer", true); } ObjectNode objectNode = createSchemaNode("string", true); if (typeHint != null) { JavaType type = provider.constructType(typeHint); if (type.isEnumType()) { ArrayNode enumNode = objectNode.putArray("enum"); for (SerializableString value : _values.values()) { enumNode.add(value.getValue()); } } } return objectNode; } @Override public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) throws JsonMappingException { // [JACKSON-684]: serialize as index? if (_serializeAsIndex(visitor.getProvider())) { JsonIntegerFormatVisitor v2 = visitor.expectIntegerFormat(typeHint); if (v2 != null) { // typically serialized as a small number (byte or int) v2.numberType(JsonParser.NumberType.INT); } } else { JsonStringFormatVisitor stringVisitor = visitor.expectStringFormat(typeHint); if (typeHint != null && stringVisitor != null) { if (typeHint.isEnumType()) { Set<String> enums = new LinkedHashSet<String>(); for (SerializableString value : _values.values()) { enums.add(value.getValue()); } stringVisitor.enumTypes(enums); } } } } /* /********************************************************** /* Helper methods /********************************************************** */ protected final boolean _serializeAsIndex(SerializerProvider provider) { if (_serializeAsIndex != null) { return _serializeAsIndex.booleanValue(); } return provider.isEnabled(SerializationFeature.WRITE_ENUMS_USING_INDEX); } /** * Helper method called to check whether */ protected static Boolean _isShapeWrittenUsingIndex(Class<?> enumClass, JsonFormat.Value format, boolean fromClass) { JsonFormat.Shape shape = (format == null) ? null : format.getShape(); if (shape == null) { return null; } if (shape == Shape.ANY || shape == Shape

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> { jgen.writeNumber(value.longValue()); } else if (value instanceof Double) { jgen.writeNumber(value.doubleValue()); } else if (value instanceof Float) { jgen.writeNumber(value.floatValue()); } else if ((value instanceof Byte) || (value instanceof Short)) { jgen.writeNumber(value.intValue()); // doesn't need to be cast to smaller numbers } else { // We'll have to use fallback "untyped" number write method jgen.writeNumber(value.toString()); } } @Override public JsonNode getSchema(SerializerProvider provider, Type typeHint) { return createSchemaNode(_isInt ? "integer" : "number", true); } @Override public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) throws JsonMappingException { if (_isInt) { JsonIntegerFormatVisitor v2 = visitor.expectIntegerFormat(typeHint); if (v2 != null) { v2.numberType(JsonParser.NumberType.BIG_INTEGER); } } else { JsonNumberFormatVisitor v2 = visitor.expectNumberFormat(typeHint); if (v2 != null) { Class<?> h = handledType(); if (h == BigDecimal.class) { v2.numberType(JsonParser.NumberType.BIG_DECIMAL); } // otherwise it's for Number... anything we could do there? } } } }

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> } ReadableObjectId entry = new ReadableObjectId(key); entry.setResolver(resolver); _objectIds.put(key, entry); return entry; } @Deprecated // since 2.4 @Override public ReadableObjectId findObjectId(Object id, ObjectIdGenerator<?> gen) { return findObjectId(id, gen, new SimpleObjectIdResolver()); } @Override public void checkUnresolvedObjectId() throws UnresolvedForwardReference { if (_objectIds == null) { return; } // 29-Dec-2014, tatu: As per [databind#299], may also just let unresolved refs be... if (!isEnabled(DeserializationFeature.FAIL_ON_UNRESOLVED_OBJECT_IDS)) { return; } UnresolvedForwardReference exception = null; for (Entry<IdKey,ReadableObjectId> entry : _objectIds.entrySet()) { ReadableObjectId roid = entry.getValue(); if (roid.hasReferringProperties()) { if (exception == null) { exception = new UnresolvedForwardReference("Unresolved forward references for: "); } for (Iterator<Referring> iterator = roid.referringProperties(); iterator.hasNext(); ) { Referring referring = iterator.next(); exception.addUnresolvedId(roid.getKey().key, referring.getBeanType(), referring.getLocation()); } } } if (exception != null) { throw exception; } } /* /********************************************************** /* Abstract methods impls, other factory methods /********************************************************** */ @SuppressWarnings("unchecked") @Override public JsonDeserializer<Object> deserializerInstance(Annotated ann, Object deserDef) throws JsonMappingException { if (deserDef == null) { return null; } JsonDeserializer<?> deser; if (deserDef instanceof JsonDeserializer) { deser = (JsonDeserializer<?>) deserDef; } else { /* Alas, there's no way to force return type of "either class * X or Y" -- need to throw an exception after the fact */ if (!(deserDef instanceof Class)) { throw new IllegalStateException("AnnotationIntrospector returned deserializer definition of type "+deserDef.getClass().getName()+"; expected type JsonDeserializer or

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> Class<JsonDeserializer> instead"); } Class<?> deserClass = (Class<?>)deserDef; // there are some known "no class" markers to consider too: if (deserClass == JsonDeserializer.None.class || ClassUtil.isBogusClass(deserClass)) { return null; } if (!JsonDeserializer.class.isAssignableFrom(deserClass)) { throw new IllegalStateException("AnnotationIntrospector returned Class "+deserClass.getName()+"; expected Class<JsonDeserializer>"); } HandlerInstantiator hi = _config.getHandlerInstantiator(); deser = (hi == null) ? null : hi.deserializerInstance(_config, ann, deserClass); if (deser == null) { deser = (JsonDeserializer<?>) ClassUtil.createInstance(deserClass, _config.canOverrideAccessModifiers()); } } // First: need to resolve if (deser instanceof ResolvableDeserializer) { ((ResolvableDeserializer) deser).resolve(this); } return (JsonDeserializer<Object>) deser; } @Override public final KeyDeserializer keyDeserializerInstance(Annotated ann, Object deserDef) throws JsonMappingException { if (deserDef == null) { return null; } KeyDeserializer deser; if (deserDef instanceof KeyDeserializer) { deser = (KeyDeserializer) deserDef; } else { if (!(deserDef instanceof Class)) { throw new IllegalStateException("AnnotationIntrospector returned key deserializer definition of type " +deserDef.getClass().getName() +"; expected type KeyDeserializer or Class<KeyDeserializer> instead"); } Class<?> deserClass = (Class<?>)deserDef; // there are some known "no class" markers to consider too: if (deserClass == KeyDeserializer.None.class || ClassUtil.isBogusClass(deserClass)) { return null; } if (!KeyDeserializer.class.isAssignableFrom(deserClass)) { throw new IllegalStateException("AnnotationIntrospector returned Class "+deserClass.getName() +"; expected Class<KeyDeserializer>"); } HandlerInstantiator hi = _config.getHandlerInstantiator(); deser = (hi == null) ? null : hi.keyDeserializerInstance(_config, ann, deserClass); if

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> */ AnnotatedMember am = property.getMutator(); if (am == null) { continue; } AnnotationIntrospector.ReferenceProperty refDef = _annotationIntrospector.findReferenceType(am); if (refDef != null && refDef.isBackReference()) { if (result == null) { result = new HashMap<String,AnnotatedMember>(); } String refName = refDef.getName(); if (result.put(refName, am) != null) { throw new IllegalArgumentException("Multiple back-reference properties with name '"+refName+"'"); } } } return result; } /* /********************************************************** /* Introspection for deserialization, factories /********************************************************** */ @Override public List<AnnotatedMethod> getFactoryMethods() { // must filter out anything that clearly is not a factory method List<AnnotatedMethod> candidates = _classInfo.getStaticMethods(); if (candidates.isEmpty()) { return candidates; } ArrayList<AnnotatedMethod> result = new ArrayList<AnnotatedMethod>(); for (AnnotatedMethod am : candidates) { if (isFactoryMethod(am)) { result.add(am); } } return result; } @Override public Constructor<?> findSingleArgConstructor(Class<?>... argTypes) { for (AnnotatedConstructor ac : _classInfo.getConstructors()) { // This list is already filtered to only include accessible /* (note: for now this is a redundant check; but in future * that may change; thus leaving here for now) */ if (ac.getParameterCount() == 1) { Class<?> actArg = ac.getRawParameterType(0); for (Class<?> expArg : argTypes) { if (expArg == actArg) { return ac.getAnnotated(); } } } } return null; } @Override public Method findFactoryMethod(Class<?>... expArgTypes) { // So, of all single-arg static methods: for (AnnotatedMethod am : _classInfo.getStaticMethods()) { if (isFactoryMethod(am)) { // And must take one of expected arg types (or supertype) Class<?> actualArgType = am.getRawParameterType(0); for (

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> logical property name as key, and * matching field as value. */ public LinkedHashMap<String,AnnotatedField> _findPropertyFields( Collection<String> ignoredProperties, boolean forSerialization) { LinkedHashMap<String,AnnotatedField> results = new LinkedHashMap<String,AnnotatedField>(); for (BeanPropertyDefinition property : _properties) { AnnotatedField f = property.getField(); if (f != null) { String name = property.getName(); if (ignoredProperties != null) { if (ignoredProperties.contains(name)) { continue; } } results.put(name, f); } } return results; } /* /********************************************************** /* Helper methods, other /********************************************************** */ @SuppressWarnings("unchecked") public Converter<Object,Object> _createConverter(Object converterDef) { if (converterDef == null) { return null; } if (converterDef instanceof Converter<?,?>) { return (Converter<Object,Object>) converterDef; } if (!(converterDef instanceof Class)) { throw new IllegalStateException("AnnotationIntrospector returned Converter definition of type " +converterDef.getClass().getName()+"; expected type Converter or Class<Converter> instead"); } Class<?> converterClass = (Class<?>)converterDef; // there are some known "no class" markers to consider too: if (converterClass == Converter.None.class || ClassUtil.isBogusClass(converterClass)) { return null; } if (!Converter.class.isAssignableFrom(converterClass)) { throw new IllegalStateException("AnnotationIntrospector returned Class " +converterClass.getName()+"; expected Class<Converter>"); } HandlerInstantiator hi = _config.getHandlerInstantiator(); Converter<?,?> conv = (hi == null) ? null : hi.converterInstance(_config, _classInfo, converterClass); if (conv == null) { conv = (Converter<?,?>) ClassUtil.createInstance(converterClass, _config.canOverrideAccessModifiers()); } return (Converter<Object,Object>) conv; } }

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> setObjectIdInfo(ObjectIdInfo objectIdInfo) { _objectIdInfo = objectIdInfo; } public void setViews(Class<?>[] views) { if (views == null) { _viewMatcher = null; } else { _viewMatcher = ViewMatcher.construct(views); } } /** * Method used to assign index for property. */ public void assignIndex(int index) { if (_propertyIndex != -1) { throw new IllegalStateException("Property '"+getName()+"' already had index ("+_propertyIndex+"), trying to assign "+index); } _propertyIndex = index; } /* /********************************************************** /* BeanProperty impl /********************************************************** */ @Override public final String getName() { return _propName.getSimpleName(); } @Override public PropertyName getFullName() { return _propName; } @Override public boolean isRequired() { return _metadata.isRequired(); } @Override public PropertyMetadata getMetadata() { return _metadata; } @Override public JavaType getType() { return _type; } @Override public PropertyName getWrapperName() { return _wrapperName; } @Override public abstract <A extends Annotation> A getAnnotation(Class<A> acls); @Override public abstract AnnotatedMember getMember(); @Override public <A extends Annotation> A getContextAnnotation(Class<A> acls) { return _contextAnnotations.get(acls); } @Override public void depositSchemaProperty(JsonObjectFormatVisitor objectVisitor) throws JsonMappingException { if (isRequired()) { objectVisitor.property(this); } else { objectVisitor.optionalProperty(this); } } /* /********************************************************** /* Accessors /********************************************************** */ protected final Class<?> getDeclaringClass() { return getMember().getDeclaringClass(); } public String getManagedReferenceName() { return _managedReferenceName; } public ObjectIdInfo getObjectIdInfo() { return _objectIdInfo; } public boolean hasValueDeserializer() { return (_valueDeserializer != null) && (_valueDeserializer != MISSING_VALUE_DESERIALIZER); } public boolean hasValueTypeDeserializer() { return (_valueTypeDeserializer != null); } public Json

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>getMessage(); if (origMsg != null) { msg.append(", problem: ").append(origMsg); } else { msg.append(" (no error message provided)"); } throw new JsonMappingException(msg.toString(), null, e); } _throwAsIOE(e); } protected IOException _throwAsIOE(Exception e) throws IOException { if (e instanceof IOException) { throw (IOException) e; } if (e instanceof RuntimeException) { throw (RuntimeException) e; } // let's wrap the innermost problem Throwable th = e; while (th.getCause() != null) { th = th.getCause(); } throw new JsonMappingException(th.getMessage(), null, th); } @Override public String toString() { return "[property '"+getName()+"']"; } }

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>, BeanProperty property) throws JsonMappingException { // note: instead of finding key deserializer, with enums we actually // work with regular deserializers (less code duplication; but not // quite as clean as it ought to be) KeyDeserializer kd = _keyDeserializer; if (kd == null) { kd = ctxt.findKeyDeserializer(_mapType.getKeyType(), property); } JsonDeserializer<?> vd = _valueDeserializer; final JavaType vt = _mapType.getContentType(); if (vd == null) { vd = ctxt.findContextualValueDeserializer(vt, property); } else { // if directly assigned, probably not yet contextual, so: vd = ctxt.handleSecondaryContextualization(vd, property, vt); } TypeDeserializer vtd = _valueTypeDeserializer; if (vtd != null) { vtd = vtd.forProperty(property); } return withResolved(kd, vd, vtd); } /** * Because of costs associated with constructing Enum resolvers, * let's cache instances by default. */ @Override public boolean isCachable() { // Important: do NOT cache if polymorphic values return (_valueDeserializer == null) && (_keyDeserializer == null) && (_valueTypeDeserializer == null); } /* /********************************************************** /* ContainerDeserializerBase API /********************************************************** */ @Override public JavaType getContentType() { return _mapType.getContentType(); } @Override public JsonDeserializer<Object> getContentDeserializer() { return _valueDeserializer; } /* /********************************************************** /* Actual deserialization /********************************************************** */ @Override public EnumMap<?,?> deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException { // Ok: must point to START_OBJECT if (jp.getCurrentToken() != JsonToken.START_OBJECT) { return _deserializeFromEmpty(jp, ctxt); } EnumMap result = constructMap(); final JsonDeserializer<Object> valueDes = _valueDeserializer; final TypeDeserializer typeDeser = _valueTypeDeserializer; while ((jp.nextToken()) == JsonToken.FIELD_NAME) { String keyName = jp.getCurrentName(); // just for error message // but we need to

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> let key deserializer handle it separately, nonetheless Enum<?> key = (Enum<?>) _keyDeserializer.deserializeKey(keyName, ctxt); if (key == null) { if (!ctxt.isEnabled(DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_AS_NULL)) { throw ctxt.weirdStringException(keyName, _enumClass, "value not one of declared Enum instance names for " +_mapType.getKeyType()); } /* 24-Mar-2012, tatu: Null won't work as a key anyway, so let's * just skip the entry then. But we must skip the value as well, if so. */ jp.nextToken(); jp.skipChildren(); continue; } // And then the value... JsonToken t = jp.nextToken(); /* note: MUST check for nulls separately: deserializers will * not handle them (and maybe fail or return bogus data) */ Object value; try { if (t == JsonToken.VALUE_NULL) { value = valueDes.getNullValue(); } else if (typeDeser == null) { value = valueDes.deserialize(jp, ctxt); } else { value = valueDes.deserializeWithType(jp, ctxt, typeDeser); } } catch (Exception e) { wrapAndThrow(e, result, keyName); return null; } result.put(key, value); } return result; } @Override public Object deserializeWithType(JsonParser jp, DeserializationContext ctxt, TypeDeserializer typeDeserializer) throws IOException, JsonProcessingException { // In future could check current token... for now this should be enough: return typeDeserializer.deserializeTypedFromObject(jp, ctxt); } protected EnumMap<?,?> constructMap() { return new EnumMap(_enumClass); } }

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>package com.fasterxml.jackson.databind.deser.std; import java.io.IOException; import java.util.concurrent.atomic.AtomicReference; import com.fasterxml.jackson.core.*; import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.deser.ContextualDeserializer; import com.fasterxml.jackson.databind.jsontype.TypeDeserializer; public class AtomicReferenceDeserializer extends StdDeserializer<AtomicReference<?>> implements ContextualDeserializer { private static final long serialVersionUID = 1L; /** * Type of value that we reference */ protected final JavaType _referencedType; protected final TypeDeserializer _valueTypeDeserializer; protected final JsonDeserializer<?> _valueDeserializer; /** * @param referencedType Parameterization of this reference */ public AtomicReferenceDeserializer(JavaType referencedType) { this(referencedType, null, null); } public AtomicReferenceDeserializer(JavaType referencedType, TypeDeserializer typeDeser, JsonDeserializer<?> deser) { super(AtomicReference.class); _referencedType = referencedType; _valueDeserializer = deser; _valueTypeDeserializer = typeDeser; } public AtomicReferenceDeserializer withResolved(TypeDeserializer typeDeser, JsonDeserializer<?> valueDeser) { return new AtomicReferenceDeserializer(_referencedType, typeDeser, valueDeser); } // Added in 2.3 @Override public AtomicReference<?> getNullValue() { return new AtomicReference<Object>(); } @Override public JsonDeserializer<?> createContextual(DeserializationContext ctxt, BeanProperty property) throws JsonMappingException { JsonDeserializer<?> deser = _valueDeserializer; TypeDeserializer typeDeser = _valueTypeDeserializer; if (deser == null) { deser = ctxt.findContextualValueDeserializer(_referencedType, property); } if (typeDeser != null) { typeDeser = typeDeser.forProperty(property); } if (deser == _valueDeserializer && typeDeser == _valueTypeDeserializer) { return this; } return withResolved(typeDeser, deser); } @Override public AtomicReference<?> deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException { /* 06-Nov-2013, tatu: Looks like the

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> */ /** * Method called to find subtypes for a specific type (class) */ protected void _collectAndResolve(AnnotatedClass annotatedType, NamedType namedType, MapperConfig<?> config, AnnotationIntrospector ai, HashMap<NamedType, NamedType> collectedSubtypes) { if (!namedType.hasName()) { String name = ai.findTypeName(annotatedType); if (name != null) { namedType = new NamedType(namedType.getType(), name); } } // First things first: is base type itself included? if (collectedSubtypes.containsKey(namedType)) { // if so, no recursion; however, may need to update name? if (namedType.hasName()) { NamedType prev = collectedSubtypes.get(namedType); if (!prev.hasName()) { collectedSubtypes.put(namedType, namedType); } } return; } // if it wasn't, add and check subtypes recursively collectedSubtypes.put(namedType, namedType); Collection<NamedType> st = ai.findSubtypes(annotatedType); if (st != null && !st.isEmpty()) { for (NamedType subtype : st) { AnnotatedClass subtypeClass = AnnotatedClass.constructWithoutSuperTypes(subtype.getType(), ai, config); // One more thing: name may be either in reference, or in subtype: if (!subtype.hasName()) { subtype = new NamedType(subtype.getType(), ai.findTypeName(subtypeClass)); } _collectAndResolve(subtypeClass, subtype, config, ai, collectedSubtypes); } } } }

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> public TypeFactory getTypeFactory() { return _config.getTypeFactory(); } /** * Diagnostics method that can be called to check whether this writer * has pre-fetched serializer to use: pre-fetching improves performance * when writer instances are reused as it avoids a per-call serializer * lookup. * * @since 2.2 */ public boolean hasPrefetchedSerializer() { return _prefetch.hasSerializer(); } /** * @since 2.3 */ public ContextAttributes getAttributes() { return _config.getAttributes(); } /* /********************************************************** /* Serialization methods; ones from ObjectCodec first /********************************************************** */ /** * Method that can be used to serialize any Java value as * JSON output, using provided {@link JsonGenerator}. */ public void writeValue(JsonGenerator gen, Object value) throws IOException, JsonGenerationException, JsonMappingException { _configureGenerator(gen); if (_config.isEnabled(SerializationFeature.CLOSE_CLOSEABLE) && (value instanceof Closeable)) { _writeCloseableValue(gen, value, _config); } else { if (_prefetch.valueSerializer != null) { _serializerProvider(_config).serializeValue(gen, value, _prefetch.rootType, _prefetch.valueSerializer); } else if (_prefetch.typeSerializer != null) { _serializerProvider(_config).serializePolymorphic(gen, value, _prefetch.typeSerializer); } else { _serializerProvider(_config).serializeValue(gen, value); } if (_config.isEnabled(SerializationFeature.FLUSH_AFTER_WRITE_VALUE)) { gen.flush(); } } } /* /********************************************************** /* Serialization methods, others /********************************************************** */ /** * Method that can be used to serialize any Java value as * JSON output, written to File provided. */ public void writeValue(File resultFile, Object value) throws IOException, JsonGenerationException, JsonMappingException { _configAndWriteValue(_generatorFactory.createGenerator(resultFile, JsonEncoding.UTF8), value); } /** * Method that can be used to serialize any Java value as * JSON output, using output stream provided (using encoding * {@link JsonEncoding#UTF8

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>}). *<p> * Note: method does not close the underlying stream explicitly * here; however, {@link JsonFactory} this mapper uses may choose * to close the stream depending on its settings (by default, * it will try to close it when {@link JsonGenerator} we construct * is closed). */ public void writeValue(OutputStream out, Object value) throws IOException, JsonGenerationException, JsonMappingException { _configAndWriteValue(_generatorFactory.createGenerator(out, JsonEncoding.UTF8), value); } /** * Method that can be used to serialize any Java value as * JSON output, using Writer provided. *<p> * Note: method does not close the underlying stream explicitly * here; however, {@link JsonFactory} this mapper uses may choose * to close the stream depending on its settings (by default, * it will try to close it when {@link JsonGenerator} we construct * is closed). */ public void writeValue(Writer w, Object value) throws IOException, JsonGenerationException, JsonMappingException { _configAndWriteValue(_generatorFactory.createGenerator(w), value); } /** * Method that can be used to serialize any Java value as * a String. Functionally equivalent to calling * {@link #writeValue(Writer,Object)} with {@link java.io.StringWriter} * and constructing String, but more efficient. *<p> * Note: prior to version 2.1, throws clause included {@link IOException}; 2.1 removed it. */ @SuppressWarnings("resource") public String writeValueAsString(Object value) throws JsonProcessingException { // alas, we have to pull the recycler directly here... SegmentedStringWriter sw = new SegmentedStringWriter(_generatorFactory._getBufferRecycler()); try { _configAndWriteValue(_generatorFactory.createGenerator(sw), value); } catch (JsonProcessingException e) { // to support [JACKSON-758] throw e; } catch (IOException e) { // shouldn't really happen, but is declared as possibility so: throw JsonMappingException.fromUnexpectedIOE(e); } return sw.getAndClear(); } /** * Method that can be used to serialize any Java

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> value as * a byte array. Functionally equivalent to calling * {@link #writeValue(Writer,Object)} with {@link java.io.ByteArrayOutputStream} * and getting bytes, but more efficient. * Encoding used will be UTF-8. *<p> * Note: prior to version 2.1, throws clause included {@link IOException}; 2.1 removed it. */ @SuppressWarnings("resource") public byte[] writeValueAsBytes(Object value) throws JsonProcessingException { ByteArrayBuilder bb = new ByteArrayBuilder(_generatorFactory._getBufferRecycler()); try { _configAndWriteValue(_generatorFactory.createGenerator(bb, JsonEncoding.UTF8), value); } catch (JsonProcessingException e) { // to support [JACKSON-758] throw e; } catch (IOException e) { // shouldn't really happen, but is declared as possibility so: throw JsonMappingException.fromUnexpectedIOE(e); } byte[] result = bb.toByteArray(); bb.release(); return result; } /* /********************************************************** /* Other public methods /********************************************************** */ /** * Method for visiting type hierarchy for given type, using specified visitor. * Visitation uses <code>Serializer</code> hierarchy and related properties *<p> * This method can be used for things like * generating <a href="http://json-schema.org/">Json Schema</a> * instance for specified type. * * @param type Type to generate schema for (possibly with generic signature) * * @since 2.2 */ public void acceptJsonFormatVisitor(JavaType type, JsonFormatVisitorWrapper visitor) throws JsonMappingException { if (type == null) { throw new IllegalArgumentException("type must be provided"); } _serializerProvider(_config).acceptJsonFormatVisitor(type, visitor); } public boolean canSerialize(Class<?> type) { return _serializerProvider(_config).hasSerializerFor(type, null); } /** * Method for checking whether instances of given type can be serialized, * and optionally why (as per {@link Throwable} returned). * * @since 2.3 */ public boolean canSerialize(Class<?> type, AtomicReference<Throwable> cause

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>package com.fasterxml.jackson.databind.ser.std; import java.lang.reflect.Type; import java.util.*; import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonArrayFormatVisitor; import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitorWrapper; /** * Intermediate base class for Lists, Collections and Arrays * that contain static (non-dynamic) value types. */ @SuppressWarnings("serial") public abstract class StaticListSerializerBase<T extends Collection<?>> extends StdSerializer<T> { protected StaticListSerializerBase(Class<?> cls) { super(cls, false); } @Deprecated // since 2.5 @Override public boolean isEmpty(T value) { return isEmpty(null, value); } @Override public boolean isEmpty(SerializerProvider provider, T value) { return (value == null) || (value.size() == 0); } @Override public JsonNode getSchema(SerializerProvider provider, Type typeHint) { return createSchemaNode("array", true).set("items", contentSchema()); } @Override public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) throws JsonMappingException { acceptContentVisitor(visitor.expectArrayFormat(typeHint)); } /* /********************************************************** /* Abstract methods for sub-classes to implement /********************************************************** */ protected abstract JsonNode contentSchema(); protected abstract void acceptContentVisitor(JsonArrayFormatVisitor visitor) throws JsonMappingException; }

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> for id property; * but no easy access. But hard to see id property being optional, * so let's consider required at this point. */ ObjectIdValueProperty idProp = new ObjectIdValueProperty(oir, PropertyMetadata.STD_REQUIRED); _beanProperties = src._beanProperties.withProperty(idProp); _vanillaProcessing = false; } } public BeanDeserializerBase(BeanDeserializerBase src, HashSet<String> ignorableProps) { super(src._beanType); _classAnnotations = src._classAnnotations; _beanType = src._beanType; _valueInstantiator = src._valueInstantiator; _delegateDeserializer = src._delegateDeserializer; _propertyBasedCreator = src._propertyBasedCreator; _backRefs = src._backRefs; _ignorableProps = ignorableProps; _ignoreAllUnknown = src._ignoreAllUnknown; _anySetter = src._anySetter; _injectables = src._injectables; _nonStandardCreation = src._nonStandardCreation; _unwrappedPropertyHandler = src._unwrappedPropertyHandler; _needViewProcesing = src._needViewProcesing; _serializationShape = src._serializationShape; _vanillaProcessing = src._vanillaProcessing; _objectIdReader = src._objectIdReader; _beanProperties = src._beanProperties; } @Override public abstract JsonDeserializer<Object> unwrappingDeserializer(NameTransformer unwrapper); public abstract BeanDeserializerBase withObjectIdReader(ObjectIdReader oir); public abstract BeanDeserializerBase withIgnorableProperties(HashSet<String> ignorableProps); /** * Fluent factory for creating a variant that can handle * POJO output as a JSON Array. Implementations may ignore this request * if no such input is possible. * * @since 2.1 */ protected abstract BeanDeserializerBase asArrayDeserializer(); /* /********************************************************** /* Validation, post-processing /********************************************************** */ /** * Method called to finalize setup of this deserializer, * after deserializer itself has been registered. * This is needed to handle recursive and transitive dependencies. */ @Override public void resolve(DeserializationContext ctxt) throws JsonMappingException { ExternalTypeHandler.Builder extTypes = null;

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> delegateCreator = _valueInstantiator.getDelegateCreator(); // Need to create a temporary property to allow contextual deserializers: BeanProperty.Std property = new BeanProperty.Std(TEMP_PROPERTY_NAME, delegateType, null, _classAnnotations, delegateCreator, PropertyMetadata.STD_OPTIONAL); TypeDeserializer td = delegateType.getTypeHandler(); if (td == null) { td = ctxt.getConfig().findTypeDeserializer(delegateType); } JsonDeserializer<Object> dd = findDeserializer(ctxt, delegateType, property); if (td != null) { td = td.forProperty(property); dd = new TypeWrappedDeserializer(td, dd); } _delegateDeserializer = dd; } if (extTypes != null) { _externalTypeIdHandler = extTypes.build(); // we consider this non-standard, to offline handling _nonStandardCreation = true; } _unwrappedPropertyHandler = unwrapped; if (unwrapped != null) { // we consider this non-standard, to offline handling _nonStandardCreation = true; } // may need to disable vanilla processing, if unwrapped handling was enabled... _vanillaProcessing = _vanillaProcessing && !_nonStandardCreation; } /** * Helper method that can be used to see if specified property is annotated * to indicate use of a converter for property value (in case of container types, * it is container type itself, not key or content type). * * @since 2.2 */ protected JsonDeserializer<Object> findConvertingDeserializer(DeserializationContext ctxt, SettableBeanProperty prop) throws JsonMappingException { final AnnotationIntrospector intr = ctxt.getAnnotationIntrospector(); if (intr != null) { Object convDef = intr.findDeserializationConverter(prop.getMember()); if (convDef != null) { Converter<Object,Object> conv = ctxt.converterInstance(prop.getMember(), convDef); JavaType delegateType = conv.getInputType(ctxt.getTypeFactory()); JsonDeserializer<?> ser = ctxt.findContextualValueDeserializer(delegateType, prop); return new StdDelegatingDeserializer<Object>(conv, delegateType, ser); } } return null; } /** * Although most of post-processing

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> is done in resolve(), we only get * access to referring property's annotations here; and this is needed * to support per-property ObjectIds. * We will also consider Shape transformations (read from Array) at this * point, since it may come from either Class definition or property. */ @Override public JsonDeserializer<?> createContextual(DeserializationContext ctxt, BeanProperty property) throws JsonMappingException { ObjectIdReader oir = _objectIdReader; // First: may have an override for Object Id: final AnnotationIntrospector intr = ctxt.getAnnotationIntrospector(); final AnnotatedMember accessor = (property == null || intr == null) ? null : property.getMember(); if (accessor != null && intr != null) { ObjectIdInfo objectIdInfo = intr.findObjectIdInfo(accessor); if (objectIdInfo != null) { // some code duplication here as well (from BeanDeserializerFactory) // 2.1: allow modifications by "id ref" annotations as well: objectIdInfo = intr.findObjectReferenceInfo(accessor, objectIdInfo); Class<?> implClass = objectIdInfo.getGeneratorType(); // Property-based generator is trickier JavaType idType; SettableBeanProperty idProp; ObjectIdGenerator<?> idGen; ObjectIdResolver resolver = ctxt.objectIdResolverInstance(accessor, objectIdInfo); if (implClass == ObjectIdGenerators.PropertyGenerator.class) { PropertyName propName = objectIdInfo.getPropertyName(); idProp = findProperty(propName); if (idProp == null) { throw new IllegalArgumentException("Invalid Object Id definition for " +handledType().getName()+": can not find property with name '"+propName+"'"); } idType = idProp.getType(); idGen = new PropertyBasedObjectIdGenerator(objectIdInfo.getScope()); } else { // other types need to be simpler JavaType type = ctxt.constructType(implClass); idType = ctxt.getTypeFactory().findTypeParameters(type, ObjectIdGenerator.class)[0]; idProp = null; idGen = ctxt.objectIdGeneratorInstance(accessor, objectIdInfo); } JsonDeserializer<?> deser = ctxt.findRootValueDeserializer(idType); oir = ObjectIdReader.construct(idType, objectIdInfo.getPropertyName(),

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> = ctxt.findObjectId(id, _objectIdReader.generator, _objectIdReader.resolver); // do we have it resolved? Object pojo = roid.resolve(); if (pojo == null) { // not yet; should wait... throw new UnresolvedForwardReference("Could not resolve Object Id ["+id+"] (for " +_beanType+").", jp.getCurrentLocation(), roid); } return pojo; } protected Object deserializeFromObjectUsingNonDefault(JsonParser jp, DeserializationContext ctxt) throws IOException { if (_delegateDeserializer != null) { return _valueInstantiator.createUsingDelegate(ctxt, _delegateDeserializer.deserialize(jp, ctxt)); } if (_propertyBasedCreator != null) { return _deserializeUsingPropertyBased(jp, ctxt); } // should only occur for abstract types... if (_beanType.isAbstract()) { throw JsonMappingException.from(jp, "Can not instantiate abstract type "+_beanType +" (need to add/enable type information?)"); } throw JsonMappingException.from(jp, "No suitable constructor found for type " +_beanType+": can not instantiate from JSON object (missing default constructor or creator, or perhaps need to add/enable type information?)"); } protected abstract Object _deserializeUsingPropertyBased(final JsonParser jp, final DeserializationContext ctxt) throws IOException, JsonProcessingException; @SuppressWarnings("incomplete-switch") public Object deserializeFromNumber(JsonParser jp, DeserializationContext ctxt) throws IOException { // First things first: id Object Id is used, most likely that's it if (_objectIdReader != null) { return deserializeFromObjectId(jp, ctxt); } switch (jp.getNumberType()) { case INT: if (_delegateDeserializer != null) { if (!_valueInstantiator.canCreateFromInt()) { Object bean = _valueInstantiator.createUsingDelegate(ctxt, _delegateDeserializer.deserialize(jp, ctxt)); if (_injectables != null) { injectValues(ctxt, bean); } return bean; } } return _valueInstantiator.createFromInt(ctxt, jp.getIntValue()); case LONG: if (_delegateDeserializer != null) { if (!_valueInstantiator.canCreateFromInt

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> via * ResolvableDeserializer (if we absolutely must...). * But for now, let's not bother. */ // subDeser = ctxt.findValueDeserializer(type, _property); subDeser = ctxt.findRootValueDeserializer(type); // Also, need to cache it if (subDeser != null) { synchronized (this) { if (_subDeserializers == null) { _subDeserializers = new HashMap<ClassKey,JsonDeserializer<Object>>();; } _subDeserializers.put(new ClassKey(bean.getClass()), subDeser); } } return subDeser; } /* /********************************************************** /* Helper methods for error reporting /********************************************************** */ /** * Method that will modify caught exception (passed in as argument) * as necessary to include reference information, and to ensure it * is a subtype of {@link IOException}, or an unchecked exception. *<p> * Rules for wrapping and unwrapping are bit complicated; essentially: *<ul> * <li>Errors are to be passed as is (if uncovered via unwrapping) * <li>"Plain" IOExceptions (ones that are not of type * {@link JsonMappingException} are to be passed as is *</ul> */ public void wrapAndThrow(Throwable t, Object bean, String fieldName, DeserializationContext ctxt) throws IOException { // [JACKSON-55] Need to add reference information throw JsonMappingException.wrapWithPath(throwOrReturnThrowable(t, ctxt), bean, fieldName); } @Deprecated // since 2.4, not used by core Jackson; only relevant for arrays/Collections public void wrapAndThrow(Throwable t, Object bean, int index, DeserializationContext ctxt) throws IOException { // [JACKSON-55] Need to add reference information throw JsonMappingException.wrapWithPath(throwOrReturnThrowable(t, ctxt), bean, index); } private Throwable throwOrReturnThrowable(Throwable t, DeserializationContext ctxt) throws IOException { /* 05-Mar-2009, tatu: But one nasty edge is when we get * StackOverflow: usually due to infinite loop. But that * often gets

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>_JAVAX_XML) || hasSupertypeStartingWith(rawType, PACKAGE_PREFIX_JAVAX_XML)) { factoryName = SERIALIZERS_FOR_JAVAX_XML; } else if (doesImplement(rawType, CLASS_NAME_DOM_NODE)) { return (JsonSerializer<?>) instantiate(SERIALIZER_FOR_DOM_NODE); } else { return null; } Object ob = instantiate(factoryName); if (ob == null) { // could warn, if we had logging system (j.u.l?) return null; } return ((Serializers) ob).findSerializer(config, type, beanDesc); } public JsonDeserializer<?> findDeserializer(JavaType type, DeserializationConfig config, BeanDescription beanDesc) throws JsonMappingException { Class<?> rawType = type.getRawClass(); String className = rawType.getName(); String factoryName; if (className.startsWith(PACKAGE_PREFIX_JAVAX_XML) || hasSupertypeStartingWith(rawType, PACKAGE_PREFIX_JAVAX_XML)) { factoryName = DESERIALIZERS_FOR_JAVAX_XML; } else if (doesImplement(rawType, CLASS_NAME_DOM_DOCUMENT)) { return (JsonDeserializer<?>) instantiate(DESERIALIZER_FOR_DOM_DOCUMENT); } else if (doesImplement(rawType, CLASS_NAME_DOM_NODE)) { return (JsonDeserializer<?>) instantiate(DESERIALIZER_FOR_DOM_NODE); } else { return null; } Object ob = instantiate(factoryName); if (ob == null) { // could warn, if we had logging system (j.u.l?) return null; } return ((Deserializers) ob).findBeanDeserializer(type, config, beanDesc); } /* /********************************************************** /* Internal helper methods /********************************************************** */ private Object instantiate(String className) { try { return Class.forName(className).newInstance(); } catch (LinkageError e) { } // too many different kinds to enumerate here: catch (Exception e) { } return null; } private boolean doesImplement(Class<?> actualType, String classNameToImplement) { for (

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> throws JsonMappingException { // Fast lookup from local lookup thingy works? JsonSerializer<Object> ser = _knownSerializers.untypedValueSerializer(valueType); if (ser == null) { // If not, maybe shared map already has it? ser = _serializerCache.untypedValueSerializer(valueType); if (ser == null) { // ... possibly as fully typed? ser = _serializerCache.untypedValueSerializer(_config.constructType(valueType)); if (ser == null) { // If neither, must create ser = _createAndCacheUntypedSerializer(valueType); // Not found? Must use the unknown type serializer, which will report error later on if (ser == null) { ser = getUnknownTypeSerializer(valueType); // Should this be added to lookups? if (CACHE_UNKNOWN_MAPPINGS) { _serializerCache.addAndResolveNonTypedSerializer(valueType, ser, this); } return ser; } } } } // at this point, resolution has occured, but not contextualization return (JsonSerializer<Object>) handleSecondaryContextualization(ser, property); } /** * Similar to {@link #findValueSerializer(Class,BeanProperty)}, but takes * full generics-aware type instead of raw class. * This is necessary for accurate handling of external type information, * to handle polymorphic types. * * @param property When creating secondary serializers, property for which * serializer is needed: annotations of the property (or bean that contains it) * may be checked to create contextual serializers. */ @SuppressWarnings("unchecked") public JsonSerializer<Object> findValueSerializer(JavaType valueType, BeanProperty property) throws JsonMappingException { // (see comments from above method) JsonSerializer<Object> ser = _knownSerializers.untypedValueSerializer(valueType); if (ser == null) { ser = _serializerCache.untypedValueSerializer(valueType); if (ser == null) { ser = _createAndCacheUntypedSerializer(valueType); if (ser == null) { ser = getUnknownTypeSerializer(valueType.getRawClass()); if (CACHE_UNKNOWN_MAPPINGS) { _serializerCache.addAndResolveNonTypedSerializer(valueType, ser,

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> this); } return ser; } } } return (JsonSerializer<Object>) handleSecondaryContextualization(ser, property); } /** * Method variant used when we do NOT want contextualization to happen; it will need * to be handled at a later point, but caller wants to be able to do that * as needed; sometimes to avoid infinite loops * * @since 2.5 */ public JsonSerializer<Object> findValueSerializer(Class<?> valueType) throws JsonMappingException { // (see comments from above method) JsonSerializer<Object> ser = _knownSerializers.untypedValueSerializer(valueType); if (ser == null) { ser = _serializerCache.untypedValueSerializer(valueType); if (ser == null) { ser = _serializerCache.untypedValueSerializer(_config.constructType(valueType)); if (ser == null) { ser = _createAndCacheUntypedSerializer(valueType); if (ser == null) { ser = getUnknownTypeSerializer(valueType); if (CACHE_UNKNOWN_MAPPINGS) { _serializerCache.addAndResolveNonTypedSerializer(valueType, ser, this); } } } } } return ser; } /** * Method variant used when we do NOT want contextualization to happen; it will need * to be handled at a later point, but caller wants to be able to do that * as needed; sometimes to avoid infinite loops * * @since 2.5 */ public JsonSerializer<Object> findValueSerializer(JavaType valueType) throws JsonMappingException { // (see comments from above method) JsonSerializer<Object> ser = _knownSerializers.untypedValueSerializer(valueType); if (ser == null) { ser = _serializerCache.untypedValueSerializer(valueType); if (ser == null) { ser = _createAndCacheUntypedSerializer(valueType); if (ser == null) { ser = getUnknownTypeSerializer(valueType.getRawClass()); if (CACHE_UNKNOWN_MAPPINGS) { _serializerCache.addAndResolveNonTypedSerializer(valueType, ser, this); } } } } return ser; } /** * Similar to {@link #findValueSerializer

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>(JavaType, BeanProperty)}, but used * when finding "primary" property value serializer (one directly handling * value of the property). Difference has to do with contextual resolution, * and method(s) called: this method should only be called when caller is * certain that this is the primary property value serializer. * * @param property Property that is being handled; will never be null, and its * type has to match <code>valueType</code> parameter. * * @since 2.3 */ @SuppressWarnings("unchecked") public JsonSerializer<Object> findPrimaryPropertySerializer(JavaType valueType, BeanProperty property) throws JsonMappingException { JsonSerializer<Object> ser = _knownSerializers.untypedValueSerializer(valueType); if (ser == null) { ser = _serializerCache.untypedValueSerializer(valueType); if (ser == null) { ser = _createAndCacheUntypedSerializer(valueType); if (ser == null) { ser = getUnknownTypeSerializer(valueType.getRawClass()); // Should this be added to lookups? if (CACHE_UNKNOWN_MAPPINGS) { _serializerCache.addAndResolveNonTypedSerializer(valueType, ser, this); } return ser; } } } return (JsonSerializer<Object>) handlePrimaryContextualization(ser, property); } /** * @since 2.3 */ @SuppressWarnings("unchecked") public JsonSerializer<Object> findPrimaryPropertySerializer(Class<?> valueType, BeanProperty property) throws JsonMappingException { JsonSerializer<Object> ser = _knownSerializers.untypedValueSerializer(valueType); if (ser == null) { ser = _serializerCache.untypedValueSerializer(valueType); if (ser == null) { ser = _serializerCache.untypedValueSerializer(_config.constructType(valueType)); if (ser == null) { ser = _createAndCacheUntypedSerializer(valueType); if (ser == null) { ser = getUnknownTypeSerializer(valueType); if (CACHE_UNKNOWN_MAPPINGS) { _serializerCache.addAndResolveNonTypedSerializer(valueType, ser, this); } return ser; } } } } return (JsonSerializer<Object>)

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> handlePrimaryContextualization(ser, property); } /** * Method called to locate regular serializer, matching type serializer, * and if both found, wrap them in a serializer that calls both in correct * sequence. This method is currently only used for root-level serializer * handling to allow for simpler caching. A call can always be replaced * by equivalent calls to access serializer and type serializer separately. * * @param valueType Type for purpose of locating a serializer; usually dynamic * runtime type, but can also be static declared type, depending on configuration * @param cache Whether resulting value serializer should be cached or not; this is just * a hint * @param property When creating secondary serializers, property for which * serializer is needed: annotations of the property (or bean that contains it) * may be checked to create contextual serializers. */ public JsonSerializer<Object> findTypedValueSerializer(Class<?> valueType, boolean cache, BeanProperty property) throws JsonMappingException { // Two-phase lookups; local non-shared cache, then shared: JsonSerializer<Object> ser = _knownSerializers.typedValueSerializer(valueType); if (ser != null) { return ser; } // If not, maybe shared map already has it? ser = _serializerCache.typedValueSerializer(valueType); if (ser != null) { return ser; } // Well, let's just compose from pieces: ser = findValueSerializer(valueType, property); TypeSerializer typeSer = _serializerFactory.createTypeSerializer(_config, _config.constructType(valueType)); if (typeSer != null) { typeSer = typeSer.forProperty(property); ser = new TypeWrappedSerializer(typeSer, ser); } if (cache) { _serializerCache.addTypedSerializer(valueType, ser); } return ser; } /** * Method called to locate regular serializer, matching type serializer, * and if both found, wrap them in a serializer that calls both in correct * sequence. This method is currently only used for root-level serializer * handling to allow for simpler caching. A call can always be replaced * by equivalent calls to access serializer and type serializer separately. * * @param valueType Declared type of value being

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> serialized (which may not * be actual runtime type); used for finding both value serializer and * type serializer to use for adding polymorphic type (if any) * @param cache Whether resulting value serializer should be cached or not; this is just * a hint * @param property When creating secondary serializers, property for which * serializer is needed: annotations of the property (or bean that contains it) * may be checked to create contextual serializers. */ public JsonSerializer<Object> findTypedValueSerializer(JavaType valueType, boolean cache, BeanProperty property) throws JsonMappingException { // Two-phase lookups; local non-shared cache, then shared: JsonSerializer<Object> ser = _knownSerializers.typedValueSerializer(valueType); if (ser != null) { return ser; } // If not, maybe shared map already has it? ser = _serializerCache.typedValueSerializer(valueType); if (ser != null) { return ser; } // Well, let's just compose from pieces: ser = findValueSerializer(valueType, property); TypeSerializer typeSer = _serializerFactory.createTypeSerializer(_config, valueType); if (typeSer != null) { typeSer = typeSer.forProperty(property); ser = new TypeWrappedSerializer(typeSer, ser); } if (cache) { _serializerCache.addTypedSerializer(valueType, ser); } return ser; } /** * Method called to get the serializer to use for serializing * non-null Map keys. Separation from regular * {@link #findValueSerializer} method is because actual write * method must be different (@link JsonGenerator#writeFieldName}; * but also since behavior for some key types may differ. *<p> * Note that the serializer itself can be called with instances * of any Java object, but not nulls. */ public JsonSerializer<Object> findKeySerializer(JavaType keyType, BeanProperty property) throws JsonMappingException { JsonSerializer<Object> ser = _serializerFactory.createKeySerializer(_config, keyType, _keySerializer); // 25-Feb-2011, tatu: As per [JACKSON-519], need to ensure contextual

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>ity works here, too return _handleContextualResolvable(ser, property); } /* /******************************************************** /* Accessors for specialized serializers /******************************************************** */ /** * @since 2.0 */ public JsonSerializer<Object> getDefaultNullKeySerializer() { return _nullKeySerializer; } /** * @since 2.0 */ public JsonSerializer<Object> getDefaultNullValueSerializer() { return _nullValueSerializer; } /** * Method called to get the serializer to use for serializing * Map keys that are nulls: this is needed since JSON does not allow * any non-String value as key, including null. *<p> * Typically, returned serializer * will either throw an exception, or use an empty String; but * other behaviors are possible. */ /** * Method called to find a serializer to use for null values for given * declared type. Note that type is completely based on declared type, * since nulls in Java have no type and thus runtime type can not be * determined. * * @since 2.0 */ public JsonSerializer<Object> findNullKeySerializer(JavaType serializationType, BeanProperty property) throws JsonMappingException { return _nullKeySerializer; } /** * Method called to get the serializer to use for serializing null * values for specified property. *<p> * Default implementation simply calls {@link #getDefaultNullValueSerializer()}; * can be overridden to add custom null serialization for properties * of certain type or name. This gives method full granularity to basically * override null handling for any specific property or class of properties. * * @since 2.0 */ public JsonSerializer<Object> findNullValueSerializer(BeanProperty property) throws JsonMappingException { return _nullValueSerializer; } /** * Method called to get the serializer to use if provider * can not determine an actual type-specific serializer * to use; typically when none of {@link SerializerFactory} * instances are able to construct a serializer. *<p> * Typically, returned serializer will throw an exception, * although alternatively {@link com.fasterxml.jackson.databind.ser.std.ToStringSerializer} * could be returned as well. * * @param unknown

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>Type Type for which no serializer is found */ public JsonSerializer<Object> getUnknownTypeSerializer(Class<?> unknownType) { return _unknownTypeSerializer; } /** * Helper method called to see if given serializer is considered to be * something returned by {@link #getUnknownTypeSerializer}, that is, something * for which no regular serializer was found or constructed. * * @since 2.5 */ public boolean isUnknownTypeSerializer(JsonSerializer<?> ser) { return (ser == _unknownTypeSerializer) || (ser == null); } /* /********************************************************** /* Methods for creating instances based on annotations /********************************************************** */ /** * Method that can be called to construct and configure serializer instance, * either given a {@link Class} to instantiate (with default constructor), * or an uninitialized serializer instance. * Either way, serialize will be properly resolved * (via {@link com.fasterxml.jackson.databind.ser.ResolvableSerializer}) and/or contextualized * (via {@link com.fasterxml.jackson.databind.ser.ContextualSerializer}) as necessary. * * @param annotated Annotated entity that contained definition * @param serDef Serializer definition: either an instance or class */ public abstract JsonSerializer<Object> serializerInstance(Annotated annotated, Object serDef) throws JsonMappingException; /* /********************************************************** /* Support for contextualization /********************************************************** */ /** * Method called for primary property serializers (ones * directly created to serialize values of a POJO property), * to handle details of resolving * {@link ContextualSerializer} with given property context. * * @param property Property for which the given primary serializer is used; never null. * * @since 2.3 */ public JsonSerializer<?> handlePrimaryContextualization(JsonSerializer<?> ser, BeanProperty property) throws JsonMappingException { if (ser != null) { if (ser instanceof ContextualSerializer) { ser = ((ContextualSerializer) ser).createContextual(this, property); } } return ser; } /** * Method called for secondary property serializers (ones * NOT directly created to serialize values of a POJO property * but instead created as a dependant serializer -- such as value serializers

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> * for structured types, or serializers for root values) * to handle details of resolving * {@link ContextualDeserializer} with given property context. * Given that these serializers are not directly related to given property * (or, in case of root value property, to any property), annotations * accessible may or may not be relevant. * * @param property Property for which serializer is used, if any; null * when deserializing root values * * @since 2.3 */ public JsonSerializer<?> handleSecondaryContextualization(JsonSerializer<?> ser, BeanProperty property) throws JsonMappingException { if (ser != null) { if (ser instanceof ContextualSerializer) { ser = ((ContextualSerializer) ser).createContextual(this, property); } } return ser; } /* /******************************************************** /* Convenience methods for serializing using default methods /******************************************************** */ /** * Convenience method that will serialize given value (which can be * null) using standard serializer locating functionality. It can * be called for all values including field and Map values, but usually * field values are best handled calling * {@link #defaultSerializeField} instead. */ public final void defaultSerializeValue(Object value, JsonGenerator jgen) throws IOException { if (value == null) { if (_stdNullValueSerializer) { // minor perf optimization jgen.writeNull(); } else { _nullValueSerializer.serialize(null, jgen, this); } } else { Class<?> cls = value.getClass(); findTypedValueSerializer(cls, true, null).serialize(value, jgen, this); } } /** * Convenience method that will serialize given field with specified * value. Value may be null. Serializer is done using the usual * null) using standard serializer locating functionality. */ public final void defaultSerializeField(String fieldName, Object value, JsonGenerator jgen) throws IOException { jgen.writeFieldName(fieldName); if (value == null) { /* Note: can't easily check for suppression at this point * any more; caller must check it. */ if (_stdNullValueSerializer) { // minor perf optimization jgen.writeNull(); } else { _nullValueSerializer.serialize(

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> } /** * Method that will handle serialization of Dates used as {@link java.util.Map} keys, * based on {@link SerializationFeature#WRITE_DATE_KEYS_AS_TIMESTAMPS} * value (and if using textual representation, configured date format) */ public void defaultSerializeDateKey(Date date, JsonGenerator jgen) throws IOException { if (isEnabled(SerializationFeature.WRITE_DATE_KEYS_AS_TIMESTAMPS)) { jgen.writeFieldName(String.valueOf(date.getTime())); } else { jgen.writeFieldName(_dateFormat().format(date)); } } public final void defaultSerializeNull(JsonGenerator jgen) throws IOException { if (_stdNullValueSerializer) { // minor perf optimization jgen.writeNull(); } else { _nullValueSerializer.serialize(null, jgen, this); } } /* /******************************************************** /* Error reporting /******************************************************** */ /** * @since 2.6 */ public JsonMappingException mappingException(String message, Object... args) { if (args != null && args.length > 0) { message = String.format(message, args); } return new JsonMappingException(message); } /* /******************************************************** /* Helper methods /******************************************************** */ protected void _reportIncompatibleRootType(Object value, JavaType rootType) throws IOException, JsonProcessingException { /* 07-Jan-2010, tatu: As per [JACKSON-456] better handle distinction between wrapper types, * primitives */ if (rootType.isPrimitive()) { Class<?> wrapperType = ClassUtil.wrapperType(rootType.getRawClass()); // If it's just difference between wrapper, primitive, let it slide if (wrapperType.isAssignableFrom(value.getClass())) { return; } } throw new JsonMappingException("Incompatible types: declared root type ("+rootType+") vs " +value.getClass().getName()); } /** * Method that will try to find a serializer, either from cache * or by constructing one; but will not return an "unknown" serializer * if this can not be done but rather returns null. * * @return Serializer if one

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> can be found, null if not. */ protected JsonSerializer<Object> _findExplicitUntypedSerializer(Class<?> runtimeType) throws JsonMappingException { // Fast lookup from local lookup thingy works? JsonSerializer<Object> ser = _knownSerializers.untypedValueSerializer(runtimeType); if (ser == null) { // If not, maybe shared map already has it? ser = _serializerCache.untypedValueSerializer(runtimeType); if (ser == null) { ser = _createAndCacheUntypedSerializer(runtimeType); } } /* 18-Sep-2014, tatu: This is unfortunate patch over related change * that pushes creation of "unknown type" serializer deeper down * in BeanSerializerFactory; as a result, we need to "undo" creation * here. */ if (isUnknownTypeSerializer(ser)) { return null; } return ser; } /* /********************************************************** /* Low-level methods for actually constructing and initializing /* serializers /********************************************************** */ /** * Method that will try to construct a value serializer; and if * one is successfully created, cache it for reuse. */ protected JsonSerializer<Object> _createAndCacheUntypedSerializer(Class<?> rawType) throws JsonMappingException { JavaType type = _config.constructType(rawType); JsonSerializer<Object> ser; try { ser = _createUntypedSerializer(type); } catch (IllegalArgumentException iae) { /* We better only expose checked exceptions, since those * are what caller is expected to handle */ throw new JsonMappingException(iae.getMessage(), null, iae); } if (ser != null) { _serializerCache.addAndResolveNonTypedSerializer(type, ser, this); } return ser; } protected JsonSerializer<Object> _createAndCacheUntypedSerializer(JavaType type) throws JsonMappingException { JsonSerializer<Object> ser; try { ser = _createUntypedSerializer(type); } catch (IllegalArgumentException iae) { /* We better only expose checked exceptions, since those * are what caller is expected to handle */ throw new JsonMappingException(iae.getMessage(), null, i

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>ae); } if (ser != null) { _serializerCache.addAndResolveNonTypedSerializer(type, ser, this); } return ser; } /** * @since 2.1 */ protected JsonSerializer<Object> _createUntypedSerializer(JavaType type) throws JsonMappingException { /* 27-Mar-2015, tatu: Wish I knew exactly why/what, but [databind#738] * can be prevented by synchronizing on cache (not on 'this', however, * since there's one instance per serialization). * Perhaps not-yet-resolved instance might be exposed too early to callers. */ synchronized (_serializerCache) { // 17-Feb-2013, tatu: Used to call deprecated method (that passed property) return (JsonSerializer<Object>)_serializerFactory.createSerializer(this, type); } } /** * Helper method called to resolve and contextualize given * serializer, if and as necessary. */ @SuppressWarnings("unchecked") protected JsonSerializer<Object> _handleContextualResolvable(JsonSerializer<?> ser, BeanProperty property) throws JsonMappingException { if (ser instanceof ResolvableSerializer) { ((ResolvableSerializer) ser).resolve(this); } return (JsonSerializer<Object>) handleSecondaryContextualization(ser, property); } @SuppressWarnings("unchecked") protected JsonSerializer<Object> _handleResolvable(JsonSerializer<?> ser) throws JsonMappingException { if (ser instanceof ResolvableSerializer) { ((ResolvableSerializer) ser).resolve(this); } return (JsonSerializer<Object>) ser; } /* /********************************************************** /* Internal methods /********************************************************** */ protected final DateFormat _dateFormat() { if (_dateFormat != null) { return _dateFormat; } /* 24-Feb-2012, tatu: At this point, all timezone configuration * should have occured, with respect to default dateformat * and timezone configuration. But we still better clone * an instance as formatters may be stateful. */ DateFormat df = _config.getDateFormat(); _dateFormat = df =

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> = new HashMap<Class<?>, Class<?>>(); } _mixins.put(targetType, mixinClass); return this; } /* /********************************************************** /* Module impl /********************************************************** */ @Override public String getModuleName() { return _name; } /** * Standard implementation handles registration of all configured * customizations: it is important that sub-classes call this * implementation (usually before additional custom logic) * if they choose to override it; otherwise customizations * will not be registered. */ @Override public void setupModule(SetupContext context) { if (_serializers != null) { context.addSerializers(_serializers); } if (_deserializers != null) { context.addDeserializers(_deserializers); } if (_keySerializers != null) { context.addKeySerializers(_keySerializers); } if (_keyDeserializers != null) { context.addKeyDeserializers(_keyDeserializers); } if (_abstractTypes != null) { context.addAbstractTypeResolver(_abstractTypes); } if (_valueInstantiators != null) { context.addValueInstantiators(_valueInstantiators); } if (_deserializerModifier != null) { context.addBeanDeserializerModifier(_deserializerModifier); } if (_serializerModifier != null) { context.addBeanSerializerModifier(_serializerModifier); } if (_subtypes != null && _subtypes.size() > 0) { context.registerSubtypes(_subtypes.toArray(new NamedType[_subtypes.size()])); } if (_namingStrategy != null) { context.setNamingStrategy(_namingStrategy); } if (_mixins != null) { for (Map.Entry<Class<?>,Class<?>> entry : _mixins.entrySet()) { context.setMixInAnnotations(entry.getKey(), entry.getValue()); } } } @Override public Version version() { return _version; } }

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> ArrayBuilders.arrayToSet(ignorable); } /* /********************************************************** /* Validation, post-processing (ResolvableDeserializer) /********************************************************** */ @Override public void resolve(DeserializationContext ctxt) throws JsonMappingException { // May need to resolve types for delegate- and/or property-based creators: if (_valueInstantiator.canCreateUsingDelegate()) { JavaType delegateType = _valueInstantiator.getDelegateType(ctxt.getConfig()); if (delegateType == null) { throw new IllegalArgumentException("Invalid delegate-creator definition for "+_mapType +": value instantiator ("+_valueInstantiator.getClass().getName() +") returned true for 'canCreateUsingDelegate()', but null for 'getDelegateType()'"); } /* Theoretically should be able to get CreatorProperty for delegate * parameter to pass; but things get tricky because DelegateCreator * may contain injectable values. So, for now, let's pass nothing. */ _delegateDeserializer = findDeserializer(ctxt, delegateType, null); } if (_valueInstantiator.canCreateFromObjectWith()) { SettableBeanProperty[] creatorProps = _valueInstantiator.getFromObjectArguments(ctxt.getConfig()); _propertyBasedCreator = PropertyBasedCreator.construct(ctxt, _valueInstantiator, creatorProps); } _standardStringKey = _isStdKeyDeser(_mapType, _keyDeserializer); } /** * Method called to finalize setup of this deserializer, * when it is known for which property deserializer is needed for. */ @Override public JsonDeserializer<?> createContextual(DeserializationContext ctxt, BeanProperty property) throws JsonMappingException { KeyDeserializer kd = _keyDeserializer; if (kd == null) { kd = ctxt.findKeyDeserializer(_mapType.getKeyType(), property); } else { if (kd instanceof ContextualKeyDeserializer) { kd = ((ContextualKeyDeserializer) kd).createContextual(ctxt, property); } } JsonDeserializer<?> vd = _valueDeserializer; // #125: May have a content converter if (property != null) { vd = findConvertingContentDeserializer(ctxt, property, vd); } final JavaType vt = _mapType.getContentType();

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> { value = valueDes.deserializeWithType(jp, ctxt, typeDeser); } /* !!! 23-Dec-2008, tatu: should there be an option to verify * that there are no duplicate field names? (and/or what * to do, keep-first or keep-last) */ if (useObjectId) { referringAccumulator.put(key, value); } else { result.put(key, value); } } catch (UnresolvedForwardReference reference) { handleUnresolvedReference(jp, referringAccumulator, key, reference); } catch (Exception e) { wrapAndThrow(e, result, fieldName); } } } /** * Optimized method used when keys can be deserialized as plain old * {@link java.lang.String}s, and there is no custom deserialized * specified. */ protected final void _readAndBindStringMap(JsonParser jp, DeserializationContext ctxt, Map<Object,Object> result) throws IOException, JsonProcessingException { JsonToken t = jp.getCurrentToken(); if (t == JsonToken.START_OBJECT) { t = jp.nextToken(); } final JsonDeserializer<Object> valueDes = _valueDeserializer; final TypeDeserializer typeDeser = _valueTypeDeserializer; MapReferringAccumulator referringAccumulator = null; boolean useObjectId = valueDes.getObjectIdReader() != null; if (useObjectId) { referringAccumulator = new MapReferringAccumulator(_mapType.getContentType().getRawClass(), result); } for (; t == JsonToken.FIELD_NAME; t = jp.nextToken()) { // Must point to field name String fieldName = jp.getCurrentName(); // And then the value... t = jp.nextToken(); if (_ignorableProperties != null && _ignorableProperties.contains(fieldName)) { jp.skipChildren(); continue; } try { // Note: must handle null explicitly here; value deserializers won't Object value; if (t == JsonToken.VALUE_NULL) { value = valueDes.getNullValue(); } else if (typeDeser == null) { value = valueDes.deserialize(jp, ctxt); } else { value = valueDes.deserializeWithType

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>(jp, ctxt, typeDeser); } if (useObjectId) { referringAccumulator.put(fieldName, value); } else { result.put(fieldName, value); } } catch (UnresolvedForwardReference reference) { handleUnresolvedReference(jp, referringAccumulator, fieldName, reference); } catch (Exception e) { wrapAndThrow(e, result, fieldName); } } } @SuppressWarnings("unchecked") public Map<Object,Object> _deserializeUsingCreator(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { final PropertyBasedCreator creator = _propertyBasedCreator; // null -> no ObjectIdReader for Maps (yet?) PropertyValueBuffer buffer = creator.startBuilding(jp, ctxt, null); JsonToken t = jp.getCurrentToken(); if (t == JsonToken.START_OBJECT) { t = jp.nextToken(); } final JsonDeserializer<Object> valueDes = _valueDeserializer; final TypeDeserializer typeDeser = _valueTypeDeserializer; for (; t == JsonToken.FIELD_NAME; t = jp.nextToken()) { String propName = jp.getCurrentName(); t = jp.nextToken(); // to get to value if (_ignorableProperties != null && _ignorableProperties.contains(propName)) { jp.skipChildren(); // and skip it (in case of array/object) continue; } // creator property? SettableBeanProperty prop = creator.findCreatorProperty(propName); if (prop != null) { // Last property to set? Object value = prop.deserialize(jp, ctxt); if (buffer.assignParameter(prop.getCreatorIndex(), value)) { jp.nextToken(); Map<Object,Object> result; try { result = (Map<Object,Object>)creator.build(ctxt, buffer); } catch (Exception e) { wrapAndThrow(e, _mapType.getRawClass(), propName); return null; } _readAndBind(jp, ctxt, result); return result; } continue; } // other property? needs buffering String fieldName = jp.getCurrentName(); Object key = _keyDeserializer.deserializeKey(fieldName, ctxt); Object value; try { if

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> (t == JsonToken.VALUE_NULL) { value = valueDes.getNullValue(); } else if (typeDeser == null) { value = valueDes.deserialize(jp, ctxt); } else { value = valueDes.deserializeWithType(jp, ctxt, typeDeser); } } catch (Exception e) { wrapAndThrow(e, _mapType.getRawClass(), propName); return null; } buffer.bufferMapProperty(key, value); } // end of JSON object? // if so, can just construct and leave... try { return (Map<Object,Object>)creator.build(ctxt, buffer); } catch (Exception e) { wrapAndThrow(e, _mapType.getRawClass(), null); return null; } } @Deprecated // since 2.5 protected void wrapAndThrow(Throwable t, Object ref) throws IOException { wrapAndThrow(t, ref, null); } private void handleUnresolvedReference(JsonParser jp, MapReferringAccumulator accumulator, Object key, UnresolvedForwardReference reference) throws JsonMappingException { if (accumulator == null) { throw JsonMappingException.from(jp, "Unresolved forward reference but no identity info.", reference); } Referring referring = accumulator.handleUnresolvedReference(reference, key); reference.getRoid().appendReferring(referring); } private final static class MapReferringAccumulator { private final Class<?> _valueType; private Map<Object,Object> _result; /** * A list of {@link MapReferring} to maintain ordering. */ private List<MapReferring> _accumulator = new ArrayList<MapReferring>(); public MapReferringAccumulator(Class<?> valueType, Map<Object, Object> result) { _valueType = valueType; _result = result; } public void put(Object key, Object value) { if (_accumulator.isEmpty()) { _result.put(key, value); } else { MapReferring ref = _accumulator.get(_accumulator.size() - 1); ref.next.put(key, value); } } public Referring handleUnresolvedReference(UnresolvedForwardReference reference, Object key) {

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> MapReferring id = new MapReferring(this, reference, _valueType, key); _accumulator.add(id); return id; } public void resolveForwardReference(Object id, Object value) throws IOException { Iterator<MapReferring> iterator = _accumulator.iterator(); // Resolve ordering after resolution of an id. This means either: // 1- adding to the result map in case of the first unresolved id. // 2- merge the content of the resolved id with its previous unresolved id. Map<Object,Object> previous = _result; while (iterator.hasNext()) { MapReferring ref = iterator.next(); if (ref.hasId(id)) { iterator.remove(); previous.put(ref.key, value); previous.putAll(ref.next); return; } previous = ref.next; } throw new IllegalArgumentException("Trying to resolve a forward reference with id [" + id + "] that wasn't previously seen as unresolved."); } } /** * Helper class to maintain processing order of value. The resolved * object associated with {@link #_id} comes before the values in * {@link _next}. */ final static class MapReferring extends Referring { private final MapReferringAccumulator _parent; public final Map<Object, Object> next = new LinkedHashMap<Object, Object>(); public final Object key; MapReferring(MapReferringAccumulator parent, UnresolvedForwardReference ref, Class<?> valueType, Object key) { super(ref, valueType); _parent = parent; this.key = key; } @Override public void handleResolvedForwardReference(Object id, Object value) throws IOException { _parent.resolveForwardReference(id, value); } } }

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>package com.fasterxml.jackson.databind.ser.impl; import java.io.IOException; import java.util.*; import com.fasterxml.jackson.core.*; import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.annotation.JacksonStdImpl; import com.fasterxml.jackson.databind.introspect.AnnotatedMember; import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonArrayFormatVisitor; import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatTypes; import com.fasterxml.jackson.databind.jsontype.TypeSerializer; import com.fasterxml.jackson.databind.ser.ContextualSerializer; import com.fasterxml.jackson.databind.ser.std.StaticListSerializerBase; /** * Efficient implement for serializing {@link List}s that contains Strings and are random-accessible. * The only complexity is due to possibility that serializer for {@link String} * may be overridde; because of this, logic is needed to ensure that the default * serializer is in use to use fastest mode, or if not, to defer to custom * String serializer. */ @JacksonStdImpl public final class IndexedStringListSerializer extends StaticListSerializerBase<List<String>> implements ContextualSerializer { private static final long serialVersionUID = 1L; public final static IndexedStringListSerializer instance = new IndexedStringListSerializer(); protected final JsonSerializer<String> _serializer; /* /********************************************************** /* Life-cycle /********************************************************** */ protected IndexedStringListSerializer() { this(null); } @SuppressWarnings("unchecked") public IndexedStringListSerializer(JsonSerializer<?> ser) { super(List.class); _serializer = (JsonSerializer<String>) ser; } @Override protected JsonNode contentSchema() { return createSchemaNode("string", true); } @Override protected void acceptContentVisitor(JsonArrayFormatVisitor visitor) throws JsonMappingException { visitor.itemsFormat(JsonFormatTypes.STRING); } /* /********************************************************** /* Post-processing /********************************************************** */ @Override public JsonSerializer<?> createContextual(SerializerProvider provider, BeanProperty property) throws JsonMappingException { /* 29-Sep-2012, tatu: Actually,

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>package com.fasterxml.jackson.databind.ser.impl; import java.io.IOException; import java.util.*; import com.fasterxml.jackson.core.*; import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.annotation.JacksonStdImpl; import com.fasterxml.jackson.databind.introspect.AnnotatedMember; import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonArrayFormatVisitor; import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatTypes; import com.fasterxml.jackson.databind.jsontype.TypeSerializer; import com.fasterxml.jackson.databind.ser.ContextualSerializer; import com.fasterxml.jackson.databind.ser.std.StaticListSerializerBase; /** * Efficient implement for serializing {@link Collection}s that contain Strings. * The only complexity is due to possibility that serializer for {@link String} * may be overridde; because of this, logic is needed to ensure that the default * serializer is in use to use fastest mode, or if not, to defer to custom * String serializer. */ @JacksonStdImpl @SuppressWarnings("serial") public class StringCollectionSerializer extends StaticListSerializerBase<Collection<String>> implements ContextualSerializer { public final static StringCollectionSerializer instance = new StringCollectionSerializer(); protected final JsonSerializer<String> _serializer; /* /********************************************************** /* Life-cycle /********************************************************** */ protected StringCollectionSerializer() { this(null); } @SuppressWarnings("unchecked") protected StringCollectionSerializer(JsonSerializer<?> ser) { super(Collection.class); _serializer = (JsonSerializer<String>) ser; } @Override protected JsonNode contentSchema() { return createSchemaNode("string", true); } @Override protected void acceptContentVisitor(JsonArrayFormatVisitor visitor) throws JsonMappingException { visitor.itemsFormat(JsonFormatTypes.STRING); } /* /********************************************************** /* Post-processing /********************************************************** */ @Override public JsonSerializer<?> createContextual(SerializerProvider provider, BeanProperty property) throws JsonMappingException { /* 29-Sep-2012, tatu: Actually, we need to do much more context

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>package com.fasterxml.jackson.databind.ser.impl; import java.io.IOException; import java.lang.reflect.Type; import com.fasterxml.jackson.core.*; import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitorWrapper; import com.fasterxml.jackson.databind.jsontype.TypeSerializer; import com.fasterxml.jackson.databind.ser.std.StdSerializer; @SuppressWarnings("serial") public class UnknownSerializer extends StdSerializer<Object> { public UnknownSerializer() { super(Object.class); } @Override public void serialize(Object value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonMappingException { // 27-Nov-2009, tatu: As per [JACKSON-201] may or may not fail... if (provider.isEnabled(SerializationFeature.FAIL_ON_EMPTY_BEANS)) { failForEmpty(value); } // But if it's fine, we'll just output empty JSON Object: jgen.writeStartObject(); jgen.writeEndObject(); } @Override public final void serializeWithType(Object value, JsonGenerator jgen, SerializerProvider provider, TypeSerializer typeSer) throws IOException, JsonGenerationException { if (provider.isEnabled(SerializationFeature.FAIL_ON_EMPTY_BEANS)) { failForEmpty(value); } typeSer.writeTypePrefixForObject(value, jgen); typeSer.writeTypeSuffixForObject(value, jgen); } @Override public JsonNode getSchema(SerializerProvider provider, Type typeHint) throws JsonMappingException { return null; } @Override public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) throws JsonMappingException { visitor.expectAnyFormat(typeHint); } protected void failForEmpty(Object value) throws JsonMappingException { throw new JsonMappingException("No serializer found for class "+value.getClass().getName()+" and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) )"); } }

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>) { return new SetterlessProperty(this, newName); } @Override public SetterlessProperty withValueDeserializer(JsonDeserializer<?> deser) { return new SetterlessProperty(this, deser); } /* /********************************************************** /* BeanProperty impl /********************************************************** */ @Override public <A extends Annotation> A getAnnotation(Class<A> acls) { return _annotated.getAnnotation(acls); } @Override public AnnotatedMember getMember() { return _annotated; } /* /********************************************************** /* Overridden methods /********************************************************** */ @Override public final void deserializeAndSet(JsonParser jp, DeserializationContext ctxt, Object instance) throws IOException, JsonProcessingException { JsonToken t = jp.getCurrentToken(); if (t == JsonToken.VALUE_NULL) { /* Hmmh. Is this a problem? We won't be setting anything, so it's * equivalent of empty Collection/Map in this case */ return; } // For [#501] fix we need to implement this but: if (_valueTypeDeserializer != null) { throw new JsonMappingException("Problem deserializing 'setterless' property (\""+getName()+"\"): no way to handle typed deser with setterless yet"); // return _valueDeserializer.deserializeWithType(jp, ctxt, _valueTypeDeserializer); } // Ok: then, need to fetch Collection/Map to modify: Object toModify; try { toModify = _getter.invoke(instance); } catch (Exception e) { _throwAsIOE(e); return; // never gets here } /* Note: null won't work, since we can't then inject anything * in. At least that's not good in common case. However, * theoretically the case where we get JSON null might * be compatible. If so, implementation could be changed. */ if (toModify == null) { throw new JsonMappingException("Problem deserializing 'setterless' property '"+getName()+"': get method returned null"); } _valueDeserializer.deserialize(jp, ctxt, toModify); } @Override public Object deserializeSetAndReturn(JsonParser jp, DeserializationContext ctxt, Object instance) throws IOException, JsonProcessingException { deserializeAndSet

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> Also: this is a superset of "forClassAnnotations", so may optimize by optional add: _cachedFCA.putIfAbsent(type, desc); } return desc; } @Override public BasicBeanDescription forDeserializationWithBuilder(DeserializationConfig cfg, JavaType type, MixInResolver r) { // no std JDK types with Builders, so: BasicBeanDescription desc = BasicBeanDescription.forDeserialization(collectPropertiesWithBuilder(cfg, type, r, false)); // this is still a superset of "forClassAnnotations", so may optimize by optional add: _cachedFCA.putIfAbsent(type, desc); return desc; } @Override public BasicBeanDescription forCreation(DeserializationConfig cfg, JavaType type, MixInResolver r) { BasicBeanDescription desc = _findStdTypeDesc(type); if (desc == null) { // As per [Databind#550], skip full introspection for some of standard // structured types as well desc = _findStdJdkCollectionDesc(cfg, type, r); if (desc == null) { desc = BasicBeanDescription.forDeserialization( collectProperties(cfg, type, r, false, "set")); } } // should this be cached for FCA? return desc; } @Override public BasicBeanDescription forClassAnnotations(MapperConfig<?> cfg, JavaType type, MixInResolver r) { BasicBeanDescription desc = _findStdTypeDesc(type); if (desc == null) { desc = _cachedFCA.get(type); if (desc == null) { boolean useAnnotations = cfg.isAnnotationProcessingEnabled(); AnnotatedClass ac = AnnotatedClass.construct(type.getRawClass(), (useAnnotations ? cfg.getAnnotationIntrospector() : null), r); desc = BasicBeanDescription.forOtherUse(cfg, type, ac); _cachedFCA.put(type, desc); } } return desc; } @Override public BasicBeanDescription forDirectClassAnnotations(MapperConfig<?> cfg, JavaType type, MixInResolver r) { BasicBeanDescription desc = _findStdTypeDesc(type); if (desc == null) { boolean use

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>package com.fasterxml.jackson.databind.deser; import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.jsontype.TypeDeserializer; import com.fasterxml.jackson.databind.type.*; /** * Interface that defines API for simple extensions that can provide additional deserializers * for various types. Access is by a single callback method; instance is to either return * a configured {@link JsonDeserializer} for specified type, or null to indicate that it * does not support handling of the type. In latter case, further calls can be made * for other providers; in former case returned deserializer is used for handling of * instances of specified type. *<p> * Unlike with {@link com.fasterxml.jackson.databind.ser.Serializers}, * multiple different methods are used since different kinds of types typically * require different kinds of inputs. */ public interface Deserializers { /** * Method called to locate serializer for specified array type. *<p> * Deserializer for element type may be passed, if configured explicitly at higher level (by * annotations, typically), but usually are not. * Type deserializer for element is passed if one is needed based on contextual information * (annotations on declared element class; or on field or method type is associated with). * * @param type Type of array instances to deserialize * @param config Configuration in effect * @param beanDesc Definition of the enumeration type that contains class annotations and * other information typically needed for building deserializers * @param elementTypeDeserializer If element type needs polymorphic type handling, this is * the type information deserializer to use; should usually be used as is when constructing * array deserializer. * @param elementDeserializer Deserializer to use for elements, if explicitly defined (by using * annotations, for exmple). May be null, in which case it should be resolved here (or using * {@link ResolvableDeserializer} callback) * * @return Deserializer to use for the type; or null if this provider does not know how to construct it */ public JsonDeserializer<?> findArrayDeserializer(ArrayType type, DeserializationConfig config, BeanDescription beanDesc, TypeDeserializer elementTypeDeserializer, JsonDeserializer<?> elementDeserializer) throws JsonMappingException; /**

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> * Method called to locate serializer for specified {@link java.util.Collection} (List, Set etc) type. *<p> * Deserializer for element type may be passed, if configured explicitly at higher level (by * annotations, typically), but usually are not. * Type deserializer for element is passed if one is needed based on contextual information * (annotations on declared element class; or on field or method type is associated with). * * @param type Type of collection instances to deserialize * @param config Configuration in effect * @param beanDesc Definition of the enumeration type that contains class annotations and * other information typically needed for building deserializers * @param elementTypeDeserializer If element type needs polymorphic type handling, this is * the type information deserializer to use; should usually be used as is when constructing * array deserializer. * @param elementDeserializer Deserializer to use for elements, if explicitly defined (by using * annotations, for exmple). May be null, in which case it should be resolved here (or using * {@link ResolvableDeserializer} callback) * * @return Deserializer to use for the type; or null if this provider does not know how to construct it */ public JsonDeserializer<?> findCollectionDeserializer(CollectionType type, DeserializationConfig config, BeanDescription beanDesc, TypeDeserializer elementTypeDeserializer, JsonDeserializer<?> elementDeserializer) throws JsonMappingException; /** * Method called to locate serializer for specified * "Collection-like" type (one that acts * like {@link java.util.Collection} but does not implement it). *<p> * Deserializer for element type may be passed, if configured explicitly at higher level (by * annotations, typically), but usually are not. * Type deserializer for element is passed if one is needed based on contextual information * (annotations on declared element class; or on field or method type is associated with). * * @param type Type of instances to deserialize * @param config Configuration in effect * @param beanDesc Definition of the enumeration type that contains class annotations and * other information typically needed for building deserializers * @param elementTypeDeserializer If element type needs polymorphic type handling, this is * the type information deserializer to use; should usually be used as is

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> when constructing * array deserializer. * @param elementDeserializer Deserializer to use for elements, if explicitly defined (by using * annotations, for exmple). May be null, in which case it should be resolved here (or using * {@link ResolvableDeserializer} callback) * * @return Deserializer to use for the type; or null if this provider does not know how to construct it */ public JsonDeserializer<?> findCollectionLikeDeserializer(CollectionLikeType type, DeserializationConfig config, BeanDescription beanDesc, TypeDeserializer elementTypeDeserializer, JsonDeserializer<?> elementDeserializer) throws JsonMappingException; /** * Method called to locate deserializer for specified {@link java.lang.Enum} type. * * @param type Type of {@link java.lang.Enum} instances to deserialize * @param config Configuration in effect * @param beanDesc Definition of the enumeration type that contains class annotations and * other information typically needed for building deserializers * * @return Deserializer to use for the type; or null if this provider does not know how to construct it */ public JsonDeserializer<?> findEnumDeserializer(Class<?> type, DeserializationConfig config, BeanDescription beanDesc) throws JsonMappingException; /** * Method called to locate deserializer for specified {@link java.util.Map} type. *<p> * Deserializer for element type may be passed, if configured explicitly at higher level (by * annotations, typically), but usually are not. * Type deserializer for element is passed if one is needed based on contextual information * (annotations on declared element class; or on field or method type is associated with). *<p> * Similarly, a {@link KeyDeserializer} may be passed, but this is only done if there is * a specific configuration override (annotations) to indicate instance to use. * Otherwise null is passed, and key deserializer needs to be obtained later during * resolution (using {@link ResolvableDeserializer#resolve}). * * @param type Type of {@link java.util.Map} instances to deserialize * @param config Configuration in effect * @param beanDesc Definition of the enumeration type that contains class annotations and * other information typically needed for building deserializers * @param keyDeserializer Key deserializer use, if it is defined

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> via annotations or other configuration; * null if default key deserializer for key type can be used. * @param elementTypeDeserializer If element type needs polymorphic type handling, this is * the type information deserializer to use; should usually be used as is when constructing * array deserializer. * @param elementDeserializer Deserializer to use for elements, if explicitly defined (by using * annotations, for exmple). May be null, in which case it should be resolved here (or using * {@link ResolvableDeserializer} callback) * * @return Deserializer to use for the type; or null if this provider does not know how to construct it */ public JsonDeserializer<?> findMapDeserializer(MapType type, DeserializationConfig config, BeanDescription beanDesc, KeyDeserializer keyDeserializer, TypeDeserializer elementTypeDeserializer, JsonDeserializer<?> elementDeserializer) throws JsonMappingException; /** * Method called to locate serializer for specified * "Map-like" type (one that acts * like {@link java.util.Map} but does not implement it). *<p> * Deserializer for element type may be passed, if configured explicitly at higher level (by * annotations, typically), but usually are not. * Type deserializer for element is passed if one is needed based on contextual information * (annotations on declared element class; or on field or method type is associated with). *<p> * Similarly, a {@link KeyDeserializer} may be passed, but this is only done if there is * a specific configuration override (annotations) to indicate instance to use. * Otherwise null is passed, and key deserializer needs to be obtained later during * resolution (using {@link ResolvableDeserializer#resolve}). * * @param type Type of {@link java.util.Map} instances to deserialize * @param config Configuration in effect * @param beanDesc Definition of the enumeration type that contains class annotations and * other information typically needed for building deserializers * @param keyDeserializer Key deserializer use, if it is defined via annotations or other configuration; * null if default key deserializer for key type can be used. * @param elementTypeDeserializer If element type needs polymorphic type handling, this is * the type information deserializer to use; should usually be used as

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> is when constructing * array deserializer. * @param elementDeserializer Deserializer to use for elements, if explicitly defined (by using * annotations, for exmple). May be null, in which case it should be resolved here (or using * {@link ResolvableDeserializer} callback) * * @return Deserializer to use for the type; or null if this provider does not know how to construct it */ public JsonDeserializer<?> findMapLikeDeserializer(MapLikeType type, DeserializationConfig config, BeanDescription beanDesc, KeyDeserializer keyDeserializer, TypeDeserializer elementTypeDeserializer, JsonDeserializer<?> elementDeserializer) throws JsonMappingException; /** * Method called to locate deserializer for specified JSON tree node type. * * @param nodeType Specific type of JSON tree nodes to deserialize * (subtype of {@link com.fasterxml.jackson.databind.JsonNode}) * @param config Configuration in effect * * @return Deserializer to use for the type; or null if this provider does not know how to construct it */ public JsonDeserializer<?> findTreeNodeDeserializer(Class<? extends JsonNode> nodeType, DeserializationConfig config, BeanDescription beanDesc) throws JsonMappingException; /** * Method called to locate deserializer for specified value type which does not belong to any other * category (not an Enum, Collection, Map, Array or tree node) * * @param type Bean type to deserialize * @param config Configuration in effect * @param beanDesc Definition of the enumeration type that contains class annotations and * other information typically needed for building deserializers * * @return Deserializer to use for the type; or null if this provider does not know how to construct it */ public JsonDeserializer<?> findBeanDeserializer(JavaType type, DeserializationConfig config, BeanDescription beanDesc) throws JsonMappingException; /* /********************************************************** /* Helper classes /********************************************************** */ /** * Basic {@link Deserializers} implementation that implements all methods but provides * no deserializers. Its main purpose is to serve as a base class so that * sub-classes only need to override methods they need, as most of the time some * of methods are not needed (especially enumeration and array deserializers are * very rarely overridden). */ public static class Base implements Deserial

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>izers { @Override public JsonDeserializer<?> findArrayDeserializer(ArrayType type, DeserializationConfig config, BeanDescription beanDesc, TypeDeserializer elementTypeDeserializer, JsonDeserializer<?> elementDeserializer) throws JsonMappingException { return null; } @Override public JsonDeserializer<?> findCollectionDeserializer(CollectionType type, DeserializationConfig config, BeanDescription beanDesc, TypeDeserializer elementTypeDeserializer, JsonDeserializer<?> elementDeserializer) throws JsonMappingException { return null; } @Override public JsonDeserializer<?> findCollectionLikeDeserializer(CollectionLikeType type, DeserializationConfig config, BeanDescription beanDesc, TypeDeserializer elementTypeDeserializer, JsonDeserializer<?> elementDeserializer) throws JsonMappingException { return null; } @Override public JsonDeserializer<?> findMapDeserializer(MapType type, DeserializationConfig config, BeanDescription beanDesc, KeyDeserializer keyDeserializer, TypeDeserializer elementTypeDeserializer, JsonDeserializer<?> elementDeserializer) throws JsonMappingException { return null; } @Override public JsonDeserializer<?> findMapLikeDeserializer(MapLikeType type, DeserializationConfig config, BeanDescription beanDesc, KeyDeserializer keyDeserializer, TypeDeserializer elementTypeDeserializer, JsonDeserializer<?> elementDeserializer) throws JsonMappingException { return null; } @Override public JsonDeserializer<?> findEnumDeserializer(Class<?> type, DeserializationConfig config, BeanDescription beanDesc) throws JsonMappingException { return null; } @Override public JsonDeserializer<?> findTreeNodeDeserializer(Class<? extends JsonNode> nodeType, DeserializationConfig config, BeanDescription beanDesc) throws JsonMappingException { return null; } @Override public JsonDeserializer<?> findBeanDeserializer(JavaType type, DeserializationConfig config, BeanDescription beanDesc) throws JsonMappingException { return null; } } }

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> _properties.size(); Map<String, POJOPropertyBuilder> all; // Need to (re)sort alphabetically? if (sort) { all = new TreeMap<String,POJOPropertyBuilder>(); } else { all = new LinkedHashMap<String,POJOPropertyBuilder>(size+size); } for (POJOPropertyBuilder prop : _properties.values()) { all.put(prop.getName(), prop); } Map<String,POJOPropertyBuilder> ordered = new LinkedHashMap<String,POJOPropertyBuilder>(size+size); // Ok: primarily by explicit order if (propertyOrder != null) { for (String name : propertyOrder) { POJOPropertyBuilder w = all.get(name); if (w == null) { // also, as per [JACKSON-268], we will allow use of "implicit" names for (POJOPropertyBuilder prop : _properties.values()) { if (name.equals(prop.getInternalName())) { w = prop; // plus re-map to external name, to avoid dups: name = prop.getName(); break; } } } if (w != null) { ordered.put(name, w); } } } // And secondly by sorting Creator properties before other unordered properties if (_creatorProperties != null) { /* As per [Issue#311], this is bit delicate; but if alphabetic ordering * is mandated, at least ensure creator properties are in alphabetic * order. Related question of creator vs non-creator is punted for now, * so creator properties still fully predate non-creator ones. */ Collection<POJOPropertyBuilder> cr; if (sort) { TreeMap<String, POJOPropertyBuilder> sorted = new TreeMap<String,POJOPropertyBuilder>(); for (POJOPropertyBuilder prop : _creatorProperties) { sorted.put(prop.getName(), prop); } cr = sorted.values(); } else { cr = _creatorProperties; } for (POJOPropertyBuilder prop : cr) { ordered.put(prop.getName(), prop); } } // And finally whatever is left (trying to put again will not change ordering)

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>getParameterCount() != 1) { continue; } _doAddInjectable(ai.findInjectableValueId(m), m); } } protected void _doAddInjectable(Object id, AnnotatedMember m) { if (id == null) { return; } if (_injectables == null) { _injectables = new LinkedHashMap<Object, AnnotatedMember>(); } AnnotatedMember prev = _injectables.put(id, m); if (prev != null) { String type = id.getClass().getName(); throw new IllegalArgumentException("Duplicate injectable value with id '" +String.valueOf(id)+"' (of type "+type+")"); } } private PropertyName _propNameFromSimple(String simpleName) { return PropertyName.construct(simpleName, null); } /* /********************************************************** /* Internal methods; removing ignored properties /********************************************************** */ /** * Method called to get rid of candidate properties that are marked * as ignored, or that are not visible. */ protected void _removeUnwantedProperties() { Iterator<Map.Entry<String,POJOPropertyBuilder>> it = _properties.entrySet().iterator(); final boolean forceNonVisibleRemoval = !_config.isEnabled(MapperFeature.INFER_PROPERTY_MUTATORS); while (it.hasNext()) { Map.Entry<String, POJOPropertyBuilder> entry = it.next(); POJOPropertyBuilder prop = entry.getValue(); // First: if nothing visible, just remove altogether if (!prop.anyVisible()) { it.remove(); continue; } // Otherwise, check ignorals if (prop.anyIgnorals()) { // first: if one or more ignorals, and no explicit markers, remove the whole thing if (!prop.isExplicitlyIncluded()) { it.remove(); _addIgnored(prop.getName()); continue; } // otherwise just remove ones marked to be ignored prop.removeIgnored(); if (!_forSerialization && !prop.couldDeserialize()) { _addIgnored(prop.getName()); } } // and finally, handle removal of individual non-visible elements prop.removeNonVisible(forceNonVisibleRemoval); } } private void _addIgnored(String name

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>) { if (!_forSerialization) { if (_ignoredPropertyNames == null) { _ignoredPropertyNames = new HashSet<String>(); } _ignoredPropertyNames.add(name); } } /* /********************************************************** /* Internal methods; renaming properties /********************************************************** */ protected void _renameProperties() { // With renaming need to do in phases: first, find properties to rename Iterator<Map.Entry<String,POJOPropertyBuilder>> it = _properties.entrySet().iterator(); LinkedList<POJOPropertyBuilder> renamed = null; while (it.hasNext()) { Map.Entry<String, POJOPropertyBuilder> entry = it.next(); POJOPropertyBuilder prop = entry.getValue(); Collection<PropertyName> l = prop.findExplicitNames(); // no explicit names? Implicit one is fine as is if (l.isEmpty()) { continue; } it.remove(); // need to replace with one or more renamed if (renamed == null) { renamed = new LinkedList<POJOPropertyBuilder>(); } // simple renaming? Just do it if (l.size() == 1) { PropertyName n = l.iterator().next(); renamed.add(prop.withName(n)); continue; } // but this may be problematic... renamed.addAll(prop.explode(l)); /* String newName = prop.findNewName(); if (newName != null) { if (renamed == null) { renamed = new LinkedList<POJOPropertyBuilder>(); } prop = prop.withSimpleName(newName); renamed.add(prop); it.remove(); } */ } // and if any were renamed, merge back in... if (renamed != null) { for (POJOPropertyBuilder prop : renamed) { String name = prop.getName(); POJOPropertyBuilder old = _properties.get(name); if (old == null) { _properties.put(name, prop); } else { old.addAll(prop); } // replace the creatorProperty too, if there is one _updateCreatorProperty(prop, _creatorProperties); } } } protected void _renameUsing(PropertyNamingStrategy naming) {

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> POJOPropertyBuilder[] props = _properties.values().toArray(new POJOPropertyBuilder[_properties.size()]); _properties.clear(); for (POJOPropertyBuilder prop : props) { PropertyName fullName = prop.getFullName(); String rename = null; // As per [#428](https://github.com/FasterXML/jackson-databind/issues/428) need // to skip renaming if property has explicitly defined name if (!prop.isExplicitlyNamed()) { if (_forSerialization) { if (prop.hasGetter()) { rename = naming.nameForGetterMethod(_config, prop.getGetter(), fullName.getSimpleName()); } else if (prop.hasField()) { rename = naming.nameForField(_config, prop.getField(), fullName.getSimpleName()); } } else { if (prop.hasSetter()) { rename = naming.nameForSetterMethod(_config, prop.getSetter(), fullName.getSimpleName()); } else if (prop.hasConstructorParameter()) { rename = naming.nameForConstructorParameter(_config, prop.getConstructorParameter(), fullName.getSimpleName()); } else if (prop.hasField()) { rename = naming.nameForField(_config, prop.getField(), fullName.getSimpleName()); } else if (prop.hasGetter()) { /* Plus, when getter-as-setter is used, need to convert that too.. * (should we verify that's enabled? For now, assume it's ok always) */ rename = naming.nameForGetterMethod(_config, prop.getGetter(), fullName.getSimpleName()); } } } final String simpleName; if (rename != null && !fullName.hasSimpleName(rename)) { prop = prop.withSimpleName(rename); simpleName = rename; } else { simpleName = fullName.getSimpleName(); } /* As per [JACKSON-687], need to consider case where there may already be * something in there... */ POJOPropertyBuilder old = _properties.get(simpleName); if (old == null) { _properties.put(simpleName, prop); } else { old.addAll(prop); } // replace the creatorProperty too, if there is one _updateCreatorProperty(prop, _creatorProperties

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>); } } protected void _renameWithWrappers() { /* 11-Sep-2012, tatu: To support 'MapperFeature.USE_WRAPPER_NAME_AS_PROPERTY_NAME', * need another round of renaming... */ Iterator<Map.Entry<String,POJOPropertyBuilder>> it = _properties.entrySet().iterator(); LinkedList<POJOPropertyBuilder> renamed = null; while (it.hasNext()) { Map.Entry<String, POJOPropertyBuilder> entry = it.next(); POJOPropertyBuilder prop = entry.getValue(); AnnotatedMember member = prop.getPrimaryMember(); if (member == null) { continue; } PropertyName wrapperName = _annotationIntrospector.findWrapperName(member); // One trickier part (wrt [Issue#24] of JAXB annotations: wrapper that // indicates use of actual property... But hopefully has been taken care // of previously if (wrapperName == null || !wrapperName.hasSimpleName()) { continue; } if (!wrapperName.equals(prop.getFullName())) { if (renamed == null) { renamed = new LinkedList<POJOPropertyBuilder>(); } prop = prop.withName(wrapperName); renamed.add(prop); it.remove(); } } // and if any were renamed, merge back in... if (renamed != null) { for (POJOPropertyBuilder prop : renamed) { String name = prop.getName(); POJOPropertyBuilder old = _properties.get(name); if (old == null) { _properties.put(name, prop); } else { old.addAll(prop); } } } } /* /********************************************************** /* Internal methods; helpers /********************************************************** */ protected void reportProblem(String msg) { throw new IllegalArgumentException("Problem with definition of "+_classDef+": "+msg); } protected POJOPropertyBuilder _property(PropertyName name) { return _property(name.getSimpleName()); } // !!! TODO: deprecate, require use of PropertyName protected POJOPropertyBuilder _property(String implName) { POJOPropertyBuilder prop = _properties.get(implName); if (

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>prop == null) { prop = new POJOPropertyBuilder(new PropertyName(implName), _annotationIntrospector, _forSerialization); _properties.put(implName, prop); } return prop; } private PropertyNamingStrategy _findNamingStrategy() { Object namingDef = (_annotationIntrospector == null)? null : _annotationIntrospector.findNamingStrategy(_classDef); if (namingDef == null) { return _config.getPropertyNamingStrategy(); } if (namingDef instanceof PropertyNamingStrategy) { return (PropertyNamingStrategy) namingDef; } /* Alas, there's no way to force return type of "either class * X or Y" -- need to throw an exception after the fact */ if (!(namingDef instanceof Class)) { throw new IllegalStateException("AnnotationIntrospector returned PropertyNamingStrategy definition of type " +namingDef.getClass().getName()+"; expected type PropertyNamingStrategy or Class<PropertyNamingStrategy> instead"); } Class<?> namingClass = (Class<?>)namingDef; if (!PropertyNamingStrategy.class.isAssignableFrom(namingClass)) { throw new IllegalStateException("AnnotationIntrospector returned Class " +namingClass.getName()+"; expected Class<PropertyNamingStrategy>"); } HandlerInstantiator hi = _config.getHandlerInstantiator(); if (hi != null) { PropertyNamingStrategy pns = hi.namingStrategyInstance(_config, _classDef, namingClass); if (pns != null) { return pns; } } return (PropertyNamingStrategy) ClassUtil.createInstance(namingClass, _config.canOverrideAccessModifiers()); } protected void _updateCreatorProperty(POJOPropertyBuilder prop, List<POJOPropertyBuilder> creatorProperties) { if (creatorProperties != null) { for (int i = 0, len = creatorProperties.size(); i < len; ++i) { if (creatorProperties.get(i).getInternalName().equals(prop.getInternalName())) { creatorProperties.set(i, prop); break; } } } } }

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>package com.fasterxml.jackson.databind.ser; import com.fasterxml.jackson.databind.*; /** * Interface used to indicate serializers that want to do post-processing * after construction and being added to {@link SerializerProvider}, * but before being used. This is typically used to resolve references * to other contained types; for example, bean serializers use this * to eagerly find serializers for contained field types. *<p> * Note that in cases where serializer needs both contextualization and * resolution -- that is, implements both this interface and {@link ContextualSerializer} * -- resolution via this interface occurs first, and contextual * resolution (using {@link ContextualSerializer}) later on. */ public interface ResolvableSerializer { /** * Method called after {@link SerializerProvider} has registered * the serializer, but before it has returned it to the caller. * Called object can then resolve its dependencies to other types, * including self-references (direct or indirect). *<p> * Note that this method does NOT return serializer, since resolution * is not allowed to change actual serializer to use. * * @param provider Provider that has constructed serializer this method * is called on. */ public abstract void resolve(SerializerProvider provider) throws JsonMappingException; }

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> to allow * copy-on-write styling copying of settings of an existing instance. */ protected MapEntryDeserializer(MapEntryDeserializer src) { super(src._type); _type = src._type; _keyDeserializer = src._keyDeserializer; _valueDeserializer = src._valueDeserializer; _valueTypeDeserializer = src._valueTypeDeserializer; } protected MapEntryDeserializer(MapEntryDeserializer src, KeyDeserializer keyDeser, JsonDeserializer<Object> valueDeser, TypeDeserializer valueTypeDeser) { super(src._type); _type = src._type; _keyDeserializer = keyDeser; _valueDeserializer = valueDeser; _valueTypeDeserializer = valueTypeDeser; } /** * Fluent factory method used to create a copy with slightly * different settings. When sub-classing, MUST be overridden. */ @SuppressWarnings("unchecked") protected MapEntryDeserializer withResolved(KeyDeserializer keyDeser, TypeDeserializer valueTypeDeser, JsonDeserializer<?> valueDeser) { if ((_keyDeserializer == keyDeser) && (_valueDeserializer == valueDeser) && (_valueTypeDeserializer == valueTypeDeser)) { return this; } return new MapEntryDeserializer(this, keyDeser, (JsonDeserializer<Object>) valueDeser, valueTypeDeser); } /* /********************************************************** /* Validation, post-processing (ResolvableDeserializer) /********************************************************** */ /** * Method called to finalize setup of this deserializer, * when it is known for which property deserializer is needed for. */ @Override public JsonDeserializer<?> createContextual(DeserializationContext ctxt, BeanProperty property) throws JsonMappingException { KeyDeserializer kd = _keyDeserializer; if (kd == null) { kd = ctxt.findKeyDeserializer(_type.containedType(0), property); } else { if (kd instanceof ContextualKeyDeserializer) { kd = ((ContextualKeyDeserializer) kd).createContextual(ctxt, property); } } JsonDeserializer<?> vd = _valueDeserializer; vd = findConvertingContentDeserializer(ctxt, property, vd); JavaType contentType = _type.containedType(1); if (vd == null) { vd = ctxt.find

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> if (Map.class.isAssignableFrom(clz)) { result = _mapType(clz); } else if (Collection.class.isAssignableFrom(clz)) { result = _collectionType(clz); } else { // 29-Sep-2014, tatu: We may want to pre-resolve well-known generic types if (Map.Entry.class.isAssignableFrom(clz)) { JavaType[] pts = this.findTypeParameters(clz, Map.Entry.class); JavaType kt, vt; if (pts == null || pts.length != 2) { kt = vt = unknownType(); } else { kt = pts[0]; vt = pts[1]; } result = constructSimpleType(clz, Map.Entry.class, new JavaType[] { kt, vt }); } else { result = new SimpleType(clz); } } _typeCache.put(key, result); // cache object syncs return result; } /** * Method used by {@link TypeParser} when generics-aware version * is constructed. */ protected JavaType _fromParameterizedClass(Class<?> clz, List<JavaType> paramTypes) { if (clz.isArray()) { // ignore generics (should never have any) return ArrayType.construct(_constructType(clz.getComponentType(), null), null, null); } if (clz.isEnum()) { // ditto for enums return new SimpleType(clz); } if (Map.class.isAssignableFrom(clz)) { // First: if we do have param types, use them JavaType keyType, contentType; if (paramTypes.size() > 0) { keyType = paramTypes.get(0); contentType = (paramTypes.size() >= 2) ? paramTypes.get(1) : _unknownType(); return MapType.construct(clz, keyType, contentType); } return _mapType(clz); } if (Collection.class.isAssignableFrom(clz)) { if (paramTypes.size() >= 1) { return CollectionType.construct(clz, paramTypes.get(0)); } return

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> /* /********************************************************** /* Overridable methods /********************************************************** */ protected void _reportProblem(JsonParser jp, String msg) throws JsonMappingException { throw new JsonMappingException(msg, jp.getTokenLocation()); } /** * * @deprecated Since 2.3, use the overloaded variant */ @Deprecated protected void _handleDuplicateField(String fieldName, ObjectNode objectNode, JsonNode oldValue, JsonNode newValue) throws JsonProcessingException { // By default, we don't do anything ; } /** * Method called when there is a duplicate value for a field. * By default we don't care, and the last value is used. * Can be overridden to provide alternate handling, such as throwing * an exception, or choosing different strategy for combining values * or choosing which one to keep. * * @param fieldName Name of the field for which duplicate value was found * @param objectNode Object node that contains values * @param oldValue Value that existed for the object node before newValue * was added * @param newValue Newly added value just added to the object node */ protected void _handleDuplicateField(JsonParser jp, DeserializationContext ctxt, JsonNodeFactory nodeFactory, String fieldName, ObjectNode objectNode, JsonNode oldValue, JsonNode newValue) throws JsonProcessingException { // [Issue#237]: Report an error if asked to do so: if (ctxt.isEnabled(DeserializationFeature.FAIL_ON_READING_DUP_TREE_KEY)) { _reportProblem(jp, "Duplicate field '"+fieldName+"' for ObjectNode: not allowed when FAIL_ON_READING_DUP_TREE_KEY enabled"); } // Backwards-compatibility; call in case it's overloaded _handleDuplicateField(fieldName, objectNode, oldValue, newValue); } /* /********************************************************** /* Helper methods /********************************************************** */ protected final ObjectNode deserializeObject(JsonParser jp, DeserializationContext ctxt, final JsonNodeFactory nodeFactory) throws IOException { ObjectNode node = nodeFactory.objectNode(); JsonToken t = jp.getCurrentToken(); if (t == JsonToken.START_OBJECT) { t = jp.nextToken(); } for (; t == JsonToken.FIELD_NAME; t = jp

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> used by module registration functionality, to construct a new bean * deserializer factory * with different configuration settings. */ @Override public DeserializerFactory withConfig(DeserializerFactoryConfig config) { if (_factoryConfig == config) { return this; } /* 22-Nov-2010, tatu: Handling of subtypes is tricky if we do immutable-with-copy-ctor; * and we pretty much have to here either choose between losing subtype instance * when registering additional deserializers, or losing deserializers. * Instead, let's actually just throw an error if this method is called when subtype * has not properly overridden this method; this to indicate problem as soon as possible. */ if (getClass() != BeanDeserializerFactory.class) { throw new IllegalStateException("Subtype of BeanDeserializerFactory ("+getClass().getName() +") has not properly overridden method 'withAdditionalDeserializers': can not instantiate subtype with " +"additional deserializer definitions"); } return new BeanDeserializerFactory(config); } /* /********************************************************** /* DeserializerFactory API implementation /********************************************************** */ /** * Method that {@link DeserializerCache}s call to create a new * deserializer for types other than Collections, Maps, arrays and * enums. */ @Override public JsonDeserializer<Object> createBeanDeserializer(DeserializationContext ctxt, JavaType type, BeanDescription beanDesc) throws JsonMappingException { final DeserializationConfig config = ctxt.getConfig(); // We may also have custom overrides: JsonDeserializer<Object> custom = _findCustomBeanDeserializer(type, config, beanDesc); if (custom != null) { return custom; } /* One more thing to check: do we have an exception type * (Throwable or its sub-classes)? If so, need slightly * different handling. */ if (type.isThrowable()) { return buildThrowableDeserializer(ctxt, type, beanDesc); } /* Or, for abstract types, may have alternate means for resolution * (defaulting, materialization) */ if (type.isAbstract()) { // [JACKSON-41] (v1.6): Let's make it possible to materialize abstract types. JavaType concreteType = materializeAbstract

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>Type(ctxt, type, beanDesc); if (concreteType != null) { /* important: introspect actual implementation (abstract class or * interface doesn't have constructors, for one) */ beanDesc = config.introspect(concreteType); return buildBeanDeserializer(ctxt, concreteType, beanDesc); } } // Otherwise, may want to check handlers for standard types, from superclass: @SuppressWarnings("unchecked") JsonDeserializer<Object> deser = (JsonDeserializer<Object>) findStdDeserializer(ctxt, type, beanDesc); if (deser != null) { return deser; } // Otherwise: could the class be a Bean class? If not, bail out if (!isPotentialBeanType(type.getRawClass())) { return null; } // Use generic bean introspection to build deserializer return buildBeanDeserializer(ctxt, type, beanDesc); } @Override public JsonDeserializer<Object> createBuilderBasedDeserializer( DeserializationContext ctxt, JavaType valueType, BeanDescription beanDesc, Class<?> builderClass) throws JsonMappingException { // First: need a BeanDescription for builder class JavaType builderType = ctxt.constructType(builderClass); BeanDescription builderDesc = ctxt.getConfig().introspectForBuilder(builderType); return buildBuilderBasedDeserializer(ctxt, valueType, builderDesc); } /** * Method called by {@link BeanDeserializerFactory} to see if there might be a standard * deserializer registered for given type. */ protected JsonDeserializer<?> findStdDeserializer(DeserializationContext ctxt, JavaType type, BeanDescription beanDesc) throws JsonMappingException { // note: we do NOT check for custom deserializers here, caller has already // done that JsonDeserializer<?> deser = findDefaultDeserializer(ctxt, type, beanDesc); // Also: better ensure these are post-processable? if (deser != null) { if (_factoryConfig.hasDeserializerModifiers()) { for (BeanDeserializerModifier mod : _factoryConfig.deserializerModifiers()) { deser = mod.modifyDeserializer(ctxt.getConfig(), beanDesc, deser); } } } return deser; } protected JavaType materializeAbstractType(DeserializationContext ctxt, JavaType type, BeanDescription beanDesc)

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> throws JsonMappingException { final JavaType abstractType = beanDesc.getType(); // [JACKSON-502]: Now it is possible to have multiple resolvers too, // as they are registered via module interface. for (AbstractTypeResolver r : _factoryConfig.abstractTypeResolvers()) { JavaType concrete = r.resolveAbstractType(ctxt.getConfig(), abstractType); if (concrete != null) { return concrete; } } return null; } /* /********************************************************** /* Public construction method beyond DeserializerFactory API: /* can be called from outside as well as overridden by /* sub-classes /********************************************************** */ /** * Method that is to actually build a bean deserializer instance. * All basic sanity checks have been done to know that what we have * may be a valid bean type, and that there are no default simple * deserializers. */ @SuppressWarnings("unchecked") public JsonDeserializer<Object> buildBeanDeserializer(DeserializationContext ctxt, JavaType type, BeanDescription beanDesc) throws JsonMappingException { // First: check what creators we can use, if any ValueInstantiator valueInstantiator = findValueInstantiator(ctxt, beanDesc); BeanDeserializerBuilder builder = constructBeanDeserializerBuilder(ctxt, beanDesc); builder.setValueInstantiator(valueInstantiator); // And then setters for deserializing from JSON Object addBeanProps(ctxt, beanDesc, builder); addObjectIdReader(ctxt, beanDesc, builder); // managed/back reference fields/setters need special handling... first part addReferenceProperties(ctxt, beanDesc, builder); addInjectables(ctxt, beanDesc, builder); final DeserializationConfig config = ctxt.getConfig(); // [JACKSON-440]: update builder now that all information is in? if (_factoryConfig.hasDeserializerModifiers()) { for (BeanDeserializerModifier mod : _factoryConfig.deserializerModifiers()) { builder = mod.updateBuilder(config, beanDesc, builder); } } JsonDeserializer<?> deserializer; /* 19-Mar-2012, tatu: This check used to be done earlier; but we have to defer * it a bit to collect information on ObjectIdReader, for example. */

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> if (type.isAbstract() && !valueInstantiator.canInstantiate()) { deserializer = builder.buildAbstract(); } else { deserializer = builder.build(); } // [JACKSON-440]: may have modifier(s) that wants to modify or replace serializer we just built: if (_factoryConfig.hasDeserializerModifiers()) { for (BeanDeserializerModifier mod : _factoryConfig.deserializerModifiers()) { deserializer = mod.modifyDeserializer(config, beanDesc, deserializer); } } return (JsonDeserializer<Object>) deserializer; } /** * Method for constructing a bean deserializer that uses specified * intermediate Builder for binding data, and construction of the * value instance. * Note that implementation is mostly copied from the regular * BeanDeserializer build method. */ @SuppressWarnings("unchecked") protected JsonDeserializer<Object> buildBuilderBasedDeserializer( DeserializationContext ctxt, JavaType valueType, BeanDescription builderDesc) throws JsonMappingException { // Creators, anyone? (to create builder itself) ValueInstantiator valueInstantiator = findValueInstantiator(ctxt, builderDesc); final DeserializationConfig config = ctxt.getConfig(); BeanDeserializerBuilder builder = constructBeanDeserializerBuilder(ctxt, builderDesc); builder.setValueInstantiator(valueInstantiator); // And then "with methods" for deserializing from JSON Object addBeanProps(ctxt, builderDesc, builder); addObjectIdReader(ctxt, builderDesc, builder); // managed/back reference fields/setters need special handling... first part addReferenceProperties(ctxt, builderDesc, builder); addInjectables(ctxt, builderDesc, builder); JsonPOJOBuilder.Value builderConfig = builderDesc.findPOJOBuilderConfig(); final String buildMethodName = (builderConfig == null) ? "build" : builderConfig.buildMethodName; // and lastly, find build method to use: AnnotatedMethod buildMethod = builderDesc.findMethod(buildMethodName, null); if (buildMethod != null) { // note: can't yet throw error; may be given build method if (config.canOverrideAccessModifiers()) { ClassUtil.checkAndFixAccess(buildMethod.getMember()); } } builder.setPOJOBuilder(buildMethod,

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> builderConfig); // this may give us more information... if (_factoryConfig.hasDeserializerModifiers()) { for (BeanDeserializerModifier mod : _factoryConfig.deserializerModifiers()) { builder = mod.updateBuilder(config, builderDesc, builder); } } JsonDeserializer<?> deserializer = builder.buildBuilderBased( valueType, buildMethodName); // [JACKSON-440]: may have modifier(s) that wants to modify or replace serializer we just built: if (_factoryConfig.hasDeserializerModifiers()) { for (BeanDeserializerModifier mod : _factoryConfig.deserializerModifiers()) { deserializer = mod.modifyDeserializer(config, builderDesc, deserializer); } } return (JsonDeserializer<Object>) deserializer; } protected void addObjectIdReader(DeserializationContext ctxt, BeanDescription beanDesc, BeanDeserializerBuilder builder) throws JsonMappingException { ObjectIdInfo objectIdInfo = beanDesc.getObjectIdInfo(); if (objectIdInfo == null) { return; } Class<?> implClass = objectIdInfo.getGeneratorType(); JavaType idType; SettableBeanProperty idProp; ObjectIdGenerator<?> gen; ObjectIdResolver resolver = ctxt.objectIdResolverInstance(beanDesc.getClassInfo(), objectIdInfo); // Just one special case: Property-based generator is trickier if (implClass == ObjectIdGenerators.PropertyGenerator.class) { // most special one, needs extra work PropertyName propName = objectIdInfo.getPropertyName(); idProp = builder.findProperty(propName); if (idProp == null) { throw new IllegalArgumentException("Invalid Object Id definition for " +beanDesc.getBeanClass().getName()+": can not find property with name '"+propName+"'"); } idType = idProp.getType(); gen = new PropertyBasedObjectIdGenerator(objectIdInfo.getScope()); } else { JavaType type = ctxt.constructType(implClass); idType = ctxt.getTypeFactory().findTypeParameters(type, ObjectIdGenerator.class)[0]; idProp = null; gen = ctxt.objectIdGeneratorInstance(beanDesc.getClassInfo(), objectIdInfo); } // also: unlike with value deserializers, let's just resolve one we need here JsonDeserializer<?> deser = ctxt.findRootValueDeserializer

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>(idType); builder.setObjectIdReader(ObjectIdReader.construct(idType, objectIdInfo.getPropertyName(), gen, deser, idProp, resolver)); } @SuppressWarnings("unchecked") public JsonDeserializer<Object> buildThrowableDeserializer(DeserializationContext ctxt, JavaType type, BeanDescription beanDesc) throws JsonMappingException { final DeserializationConfig config = ctxt.getConfig(); // first: construct like a regular bean deserializer... BeanDeserializerBuilder builder = constructBeanDeserializerBuilder(ctxt, beanDesc); builder.setValueInstantiator(findValueInstantiator(ctxt, beanDesc)); addBeanProps(ctxt, beanDesc, builder); // (and assume there won't be any back references) // But then let's decorate things a bit /* To resolve [JACKSON-95], need to add "initCause" as setter * for exceptions (sub-classes of Throwable). */ AnnotatedMethod am = beanDesc.findMethod("initCause", INIT_CAUSE_PARAMS); if (am != null) { // should never be null SimpleBeanPropertyDefinition propDef = SimpleBeanPropertyDefinition.construct(ctxt.getConfig(), am, new PropertyName("cause")); SettableBeanProperty prop = constructSettableProperty(ctxt, beanDesc, propDef, am.getGenericParameterType(0)); if (prop != null) { /* 21-Aug-2011, tatus: We may actually have found 'cause' property * to set (with new 1.9 code)... but let's replace it just in case, * otherwise can end up with odd errors. */ builder.addOrReplaceProperty(prop, true); } } // And also need to ignore "localizedMessage" builder.addIgnorable("localizedMessage"); // [JACKSON-794]: JDK 7 also added "getSuppressed", skip if we have such data: builder.addIgnorable("suppressed"); /* As well as "message": it will be passed via constructor, * as there's no 'setMessage()' method */ builder.addIgnorable("message"); // [JACKSON-440]: update builder now that all information is in? if (_factoryConfig.hasDeserializerModifiers()) { for (Bean

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>DeserializerModifier mod : _factoryConfig.deserializerModifiers()) { builder = mod.updateBuilder(config, beanDesc, builder); } } JsonDeserializer<?> deserializer = builder.build(); /* At this point it ought to be a BeanDeserializer; if not, must assume * it's some other thing that can handle deserialization ok... */ if (deserializer instanceof BeanDeserializer) { deserializer = new ThrowableDeserializer((BeanDeserializer) deserializer); } // [JACKSON-440]: may have modifier(s) that wants to modify or replace serializer we just built: if (_factoryConfig.hasDeserializerModifiers()) { for (BeanDeserializerModifier mod : _factoryConfig.deserializerModifiers()) { deserializer = mod.modifyDeserializer(config, beanDesc, deserializer); } } return (JsonDeserializer<Object>) deserializer; } /* /********************************************************** /* Helper methods for Bean deserializer construction, /* overridable by sub-classes /********************************************************** */ /** * Overridable method that constructs a {@link BeanDeserializerBuilder} * which is used to accumulate information needed to create deserializer * instance. */ protected BeanDeserializerBuilder constructBeanDeserializerBuilder(DeserializationContext ctxt, BeanDescription beanDesc) { return new BeanDeserializerBuilder(beanDesc, ctxt.getConfig()); } /** * Method called to figure out settable properties for the * bean deserializer to use. *<p> * Note: designed to be overridable, and effort is made to keep interface * similar between versions. */ protected void addBeanProps(DeserializationContext ctxt, BeanDescription beanDesc, BeanDeserializerBuilder builder) throws JsonMappingException { final SettableBeanProperty[] creatorProps = builder.getValueInstantiator().getFromObjectArguments(ctxt.getConfig()); final boolean isConcrete = !beanDesc.getType().isAbstract(); // Things specified as "ok to ignore"? [JACKSON-77] AnnotationIntrospector intr = ctxt.getAnnotationIntrospector(); boolean ignoreAny = false; { Boolean B = intr.findIgnoreUnknownProperties(beanDesc.getClassInfo()); if (B != null) { ignoreAny = B.booleanValue(); builder.setIgnoreUnknownProperties(ignoreAny);

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>[] views = propDef.findViews(); if (views == null) { // one more twist: if default inclusion disabled, need to force empty set of views if (!ctxt.isEnabled(MapperFeature.DEFAULT_VIEW_INCLUSION)) { views = NO_VIEWS; } } // one more thing before adding to builder: copy any metadata prop.setViews(views); builder.addProperty(prop); } } } /** * Helper method called to filter out explicit ignored properties, * as well as properties that have "ignorable types". * Note that this will not remove properties that have no * setters. */ protected List<BeanPropertyDefinition> filterBeanProps(DeserializationContext ctxt, BeanDescription beanDesc, BeanDeserializerBuilder builder, List<BeanPropertyDefinition> propDefsIn, Set<String> ignored) throws JsonMappingException { ArrayList<BeanPropertyDefinition> result = new ArrayList<BeanPropertyDefinition>( Math.max(4, propDefsIn.size())); HashMap<Class<?>,Boolean> ignoredTypes = new HashMap<Class<?>,Boolean>(); // These are all valid setters, but we do need to introspect bit more for (BeanPropertyDefinition property : propDefsIn) { String name = property.getName(); if (ignored.contains(name)) { // explicit ignoral using @JsonIgnoreProperties needs to block entries continue; } if (!property.hasConstructorParameter()) { // never skip constructor params Class<?> rawPropertyType = null; if (property.hasSetter()) { rawPropertyType = property.getSetter().getRawParameterType(0); } else if (property.hasField()) { rawPropertyType = property.getField().getRawType(); } // [JACKSON-429] Some types are declared as ignorable as well if ((rawPropertyType != null) && (isIgnorableType(ctxt.getConfig(), beanDesc, rawPropertyType, ignoredTypes))) { // important: make ignorable, to avoid errors if value is actually seen builder.addIgnorable(name); continue; } } result.add(property); } return result; } /** * Method that will find if bean has any managed- or back-reference properties, * and if so add them to

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> bean, to be linked during resolution phase. */ protected void addReferenceProperties(DeserializationContext ctxt, BeanDescription beanDesc, BeanDeserializerBuilder builder) throws JsonMappingException { // and then back references, not necessarily found as regular properties Map<String,AnnotatedMember> refs = beanDesc.findBackReferenceProperties(); if (refs != null) { for (Map.Entry<String, AnnotatedMember> en : refs.entrySet()) { String name = en.getKey(); AnnotatedMember m = en.getValue(); Type genericType; if (m instanceof AnnotatedMethod) { genericType = ((AnnotatedMethod) m).getGenericParameterType(0); } else { genericType = m.getRawType(); } SimpleBeanPropertyDefinition propDef = SimpleBeanPropertyDefinition.construct( ctxt.getConfig(), m); builder.addBackReferenceProperty(name, constructSettableProperty( ctxt, beanDesc, propDef, genericType)); } } } /** * Method called locate all members used for value injection (if any), * constructor {@link com.fasterxml.jackson.databind.deser.impl.ValueInjector} instances, and add them to builder. */ protected void addInjectables(DeserializationContext ctxt, BeanDescription beanDesc, BeanDeserializerBuilder builder) throws JsonMappingException { Map<Object, AnnotatedMember> raw = beanDesc.findInjectables(); if (raw != null) { boolean fixAccess = ctxt.canOverrideAccessModifiers(); for (Map.Entry<Object, AnnotatedMember> entry : raw.entrySet()) { AnnotatedMember m = entry.getValue(); if (fixAccess) { m.fixAccess(); // to ensure we can call it } builder.addInjectable(new PropertyName(m.getName()), beanDesc.resolveType(m.getGenericType()), beanDesc.getClassAnnotations(), m, entry.getKey()); } } } /** * Method called to construct fallback {@link SettableAnyProperty} * for handling unknown bean properties, given a method that * has been designated as such setter. */ protected SettableAnyProperty constructAnySetter(DeserializationContext ctxt, BeanDescription beanDesc, AnnotatedMethod setter) throws JsonMappingException { if (ctxt.

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>canOverrideAccessModifiers()) { setter.fixAccess(); // to ensure we can call it } // we know it's a 2-arg method, second arg is the value JavaType type = beanDesc.bindingsForBeanType().resolveType(setter.getGenericParameterType(1)); BeanProperty.Std property = new BeanProperty.Std(new PropertyName(setter.getName()), type, null, beanDesc.getClassAnnotations(), setter, PropertyMetadata.STD_OPTIONAL); type = resolveType(ctxt, beanDesc, type, setter); /* AnySetter can be annotated with @JsonClass (etc) just like a * regular setter... so let's see if those are used. * Returns null if no annotations, in which case binding will * be done at a later point. */ JsonDeserializer<Object> deser = findDeserializerFromAnnotation(ctxt, setter); /* Otherwise, method may specify more specific (sub-)class for * value (no need to check if explicit deser was specified): */ type = modifyTypeByAnnotation(ctxt, setter, type); if (deser == null) { deser = type.getValueHandler(); } TypeDeserializer typeDeser = type.getTypeHandler(); return new SettableAnyProperty(property, setter, type, deser, typeDeser); } /** * Method that will construct a regular bean property setter using * the given setter method. * * @return Property constructed, if any; or null to indicate that * there should be no property based on given definitions. */ protected SettableBeanProperty constructSettableProperty(DeserializationContext ctxt, BeanDescription beanDesc, BeanPropertyDefinition propDef, Type jdkType) throws JsonMappingException { // need to ensure method is callable (for non-public) AnnotatedMember mutator = propDef.getNonConstructorMutator(); if (ctxt.canOverrideAccessModifiers()) { mutator.fixAccess(); } // note: this works since we know there's exactly one argument for methods JavaType t0 = beanDesc.resolveType(jdkType); BeanProperty.Std property = new BeanProperty.Std(propDef.getFullName(), t0, propDef.getWrapperName(), beanDesc.getClassAnnotations(), mutator, propDef.getMetadata());

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> JavaType type = resolveType(ctxt, beanDesc, t0, mutator); // did type change? if (type != t0) { property = property.withType(type); } /* First: does the Method specify the deserializer to use? * If so, let's use it. */ JsonDeserializer<Object> propDeser = findDeserializerFromAnnotation(ctxt, mutator); type = modifyTypeByAnnotation(ctxt, mutator, type); TypeDeserializer typeDeser = type.getTypeHandler(); SettableBeanProperty prop; if (mutator instanceof AnnotatedMethod) { prop = new MethodProperty(propDef, type, typeDeser, beanDesc.getClassAnnotations(), (AnnotatedMethod) mutator); } else { prop = new FieldProperty(propDef, type, typeDeser, beanDesc.getClassAnnotations(), (AnnotatedField) mutator); } if (propDeser != null) { prop = prop.withValueDeserializer(propDeser); } // [JACKSON-235]: need to retain name of managed forward references: AnnotationIntrospector.ReferenceProperty ref = propDef.findReferenceType(); if (ref != null && ref.isManagedReference()) { prop.setManagedReferenceName(ref.getName()); } ObjectIdInfo objectIdInfo = propDef.findObjectIdInfo(); if(objectIdInfo != null){ prop.setObjectIdInfo(objectIdInfo); } return prop; } /** * Method that will construct a regular bean property setter using * the given setter method. */ protected SettableBeanProperty constructSetterlessProperty(DeserializationContext ctxt, BeanDescription beanDesc, BeanPropertyDefinition propDef) throws JsonMappingException { final AnnotatedMethod getter = propDef.getGetter(); // need to ensure it is callable now: if (ctxt.canOverrideAccessModifiers()) { getter.fixAccess(); } /* 26-Jan-2012, tatu: Alas, this complication is still needed to handle * (or at least work around) local type declarations... */ JavaType type = getter.getType(beanDesc.bindingsForBeanType()); /* First: does the Method specify the deserializer to use? * If

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>package com.fasterxml.jackson.databind.ser; import com.fasterxml.jackson.databind.*; /** * Add-on interface that {@link JsonSerializer}s can implement to get a callback * that can be used to create contextual instances of serializer to use for * handling properties of supported type. This can be useful * for serializers that can be configured by annotations, or should otherwise * have differing behavior depending on what kind of property is being serialized. *<p> * Note that in cases where serializer needs both contextualization and * resolution -- that is, implements both this interface and {@link ResolvableSerializer} * -- resolution via {@link ResolvableSerializer} occurs first, and contextual * resolution (via this interface) later on. */ public interface ContextualSerializer { /** * Method called to see if a different (or differently configured) serializer * is needed to serialize values of specified property. * Note that instance that this method is called on is typically shared one and * as a result method should <b>NOT</b> modify this instance but rather construct * and return a new instance. This instance should only be returned as-is, in case * it is already suitable for use. * * @param prov Serializer provider to use for accessing config, other serializers * @param property Method or field that represents the property * (and is used to access value to serialize). * Should be available; but there may be cases where caller can not provide it and * null is passed instead (in which case impls usually pass 'this' serializer as is) * * @return Serializer to use for serializing values of specified property; * may be this instance or a new instance. * * @throws JsonMappingException */ public JsonSerializer<?> createContextual(SerializerProvider prov, BeanProperty property) throws JsonMappingException; }

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>package com.fasterxml.jackson.databind.ser.std; import java.io.IOException; import java.lang.reflect.Type; import java.util.concurrent.atomic.AtomicReference; import com.fasterxml.jackson.core.*; import com.fasterxml.jackson.databind.JavaType; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.JsonSerializable; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.annotation.JacksonStdImpl; import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitorWrapper; import com.fasterxml.jackson.databind.jsonschema.JsonSerializableSchema; import com.fasterxml.jackson.databind.jsontype.TypeSerializer; import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.type.TypeFactory; /** * Generic handler for types that implement {@link JsonSerializable}. *<p> * Note: given that this is used for anything that implements * interface, can not be checked for direct class equivalence. */ @JacksonStdImpl @SuppressWarnings("serial") public class SerializableSerializer extends StdSerializer<JsonSerializable> { public final static SerializableSerializer instance = new SerializableSerializer(); // Ugh. Should NOT need this... private final static AtomicReference<ObjectMapper> _mapperReference = new AtomicReference<ObjectMapper>(); protected SerializableSerializer() { super(JsonSerializable.class); } @Override public void serialize(JsonSerializable value, JsonGenerator jgen, SerializerProvider provider) throws IOException { value.serialize(jgen, provider); } @Override public final void serializeWithType(JsonSerializable value, JsonGenerator jgen, SerializerProvider provider, TypeSerializer typeSer) throws IOException { value.serializeWithType(jgen, provider, typeSer); } @Override @SuppressWarnings("deprecation") public JsonNode getSchema(SerializerProvider provider, Type typeHint) throws JsonMappingException { ObjectNode objectNode = createObjectNode(); String schemaType = "any"; String objectProperties = null; String itemDefinition = null;

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> if (typeHint != null) { Class<?> rawClass = TypeFactory.rawClass(typeHint); if (rawClass.isAnnotationPresent(JsonSerializableSchema.class)) { JsonSerializableSchema schemaInfo = rawClass.getAnnotation(JsonSerializableSchema.class); schemaType = schemaInfo.schemaType(); if (!JsonSerializableSchema.NO_VALUE.equals(schemaInfo.schemaObjectPropertiesDefinition())) { objectProperties = schemaInfo.schemaObjectPropertiesDefinition(); } if (!JsonSerializableSchema.NO_VALUE.equals(schemaInfo.schemaItemDefinition())) { itemDefinition = schemaInfo.schemaItemDefinition(); } } } /* 19-Mar-2012, tatu: geez, this is butt-ugly abonimation of code... * really, really should not require back ref to an ObjectMapper. */ objectNode.put("type", schemaType); if (objectProperties != null) { try { objectNode.put("properties", _getObjectMapper().readTree(objectProperties)); } catch (IOException e) { throw new JsonMappingException("Failed to parse @JsonSerializableSchema.schemaObjectPropertiesDefinition value"); } } if (itemDefinition != null) { try { objectNode.put("items", _getObjectMapper().readTree(itemDefinition)); } catch (IOException e) { throw new JsonMappingException("Failed to parse @JsonSerializableSchema.schemaItemDefinition value"); } } // always optional, no need to specify: //objectNode.put("required", false); return objectNode; } private final static synchronized ObjectMapper _getObjectMapper() { ObjectMapper mapper = _mapperReference.get(); if (mapper == null) { mapper = new ObjectMapper(); _mapperReference.set(mapper); } return mapper; } @Override public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) throws JsonMappingException { visitor.expectAnyFormat(typeHint); } }

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>); if (wrap) { gen.writeEndObject(); } } catch (IOException ioe) { // As per [JACKSON-99], pass IOException and subtypes as-is throw ioe; } catch (Exception e) { // but wrap RuntimeExceptions, to get path information String msg = e.getMessage(); if (msg == null) { msg = "[no message for "+e.getClass().getName()+"]"; } throw new JsonMappingException(msg, e); } } /** * The method to be called by {@link ObjectMapper} and {@link ObjectWriter} * for serializing given value (assumed to be of specified root type, * instead of runtime type of value), * using serializers that * this provider has access to (via caching and/or creating new serializers * as need be), * * @param rootType Type to use for locating serializer to use, instead of actual * runtime type. Must be actual type, or one of its super types */ public void serializeValue(JsonGenerator gen, Object value, JavaType rootType) throws IOException { if (value == null) { _serializeNull(gen); return; } // Let's ensure types are compatible at this point if (!rootType.getRawClass().isAssignableFrom(value.getClass())) { _reportIncompatibleRootType(value, rootType); } // root value, not reached via property: JsonSerializer<Object> ser = findTypedValueSerializer(rootType, true, null); // Ok: should we wrap result in an additional property ("root name")? final boolean wrap; String rootName = _config.getRootName(); if (rootName == null) { // not explicitly specified // [JACKSON-163] wrap = _config.isEnabled(SerializationFeature.WRAP_ROOT_VALUE); if (wrap) { gen.writeStartObject(); PropertyName pname = _rootNames.findRootName(value.getClass(), _config); gen.writeFieldName(pname.simpleAsEncoded(_config)); } } else if (rootName.length() == 0) { wrap = false; } else { // [JACKSON-764] // empty String means explicitly disabled; non-

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>empty that it is enabled wrap = true; gen.writeStartObject(); gen.writeFieldName(rootName); } try { ser.serialize(value, gen, this); if (wrap) { gen.writeEndObject(); } } catch (IOException ioe) { // no wrapping for IO (and derived) throw ioe; } catch (Exception e) { // but others do need to be, to get path etc String msg = e.getMessage(); if (msg == null) { msg = "[no message for "+e.getClass().getName()+"]"; } throw new JsonMappingException(msg, e); } } /** * The method to be called by {@link ObjectWriter} * for serializing given value (assumed to be of specified root type, * instead of runtime type of value), when it may know specific * {@link JsonSerializer} to use. * * @param rootType Type to use for locating serializer to use, instead of actual * runtime type, if no serializer is passed * @param ser Root Serializer to use, if not null * * @since 2.1 */ public void serializeValue(JsonGenerator gen, Object value, JavaType rootType, JsonSerializer<Object> ser) throws IOException { if (value == null) { _serializeNull(gen); return; } // Let's ensure types are compatible at this point if ((rootType != null) && !rootType.getRawClass().isAssignableFrom(value.getClass())) { _reportIncompatibleRootType(value, rootType); } // root value, not reached via property: if (ser == null) { ser = findTypedValueSerializer(rootType, true, null); } // Ok: should we wrap result in an additional property ("root name")? final boolean wrap; String rootName = _config.getRootName(); if (rootName == null) { // not explicitly specified // [JACKSON-163] wrap = _config.isEnabled(SerializationFeature.WRAP_ROOT_VALUE); if (wrap) { gen.writeStartObject(); PropertyName pname = (rootType == null) ? _rootNames.findRootName(value.getClass(), _config)

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> : _rootNames.findRootName(rootType, _config); gen.writeFieldName(pname.simpleAsEncoded(_config)); } } else if (rootName.length() == 0) { wrap = false; } else { // [JACKSON-764] // empty String means explicitly disabled; non-empty that it is enabled wrap = true; gen.writeStartObject(); gen.writeFieldName(rootName); } try { ser.serialize(value, gen, this); if (wrap) { gen.writeEndObject(); } } catch (IOException ioe) { // no wrapping for IO (and derived) throw ioe; } catch (Exception e) { // but others do need to be, to get path etc String msg = e.getMessage(); if (msg == null) { msg = "[no message for "+e.getClass().getName()+"]"; } throw new JsonMappingException(msg, e); } } /** * Alternate serialization call used for polymorphic types, when {@link TypeSerializer} * is already known, but not actual value serializer. * * @since 2.5 */ public void serializePolymorphic(JsonGenerator gen, Object value, TypeSerializer typeSer) throws IOException { if (value == null) { _serializeNull(gen); return; } final Class<?> type = value.getClass(); JsonSerializer<Object> ser = findValueSerializer(type, null); final boolean wrap; String rootName = _config.getRootName(); if (rootName == null) { wrap = _config.isEnabled(SerializationFeature.WRAP_ROOT_VALUE); if (wrap) { gen.writeStartObject(); PropertyName pname = _rootNames.findRootName(type, _config); gen.writeFieldName(pname.simpleAsEncoded(_config)); } } else if (rootName.length() == 0) { wrap = false; } else { wrap = true; gen.writeStartObject(); gen.writeFieldName(rootName); } try { ser.serializeWithType(value, gen, this, typeSer); if (wrap) { gen.writeEndObject(); } } catch

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> (IOException ioe) { // no wrapping for IO (and derived) throw ioe; } catch (Exception e) { // but others do need to be, to get path etc String msg = e.getMessage(); if (msg == null) { msg = "[no message for "+e.getClass().getName()+"]"; } throw new JsonMappingException(msg, e); } } /** * Helper method called when root value to serialize is null * * @since 2.3 */ protected void _serializeNull(JsonGenerator gen) throws IOException { JsonSerializer<Object> ser = getDefaultNullValueSerializer(); try { ser.serialize(null, gen, this); } catch (IOException ioe) { // no wrapping for IO (and derived) throw ioe; } catch (Exception e) { // but others do need to be, to get path etc String msg = e.getMessage(); if (msg == null) { msg = "[no message for "+e.getClass().getName()+"]"; } throw new JsonMappingException(msg, e); } } /** * The method to be called by {@link ObjectMapper} and {@link ObjectWriter} * to generate <a href="http://json-schema.org/">JSON schema</a> for * given type. * * @param type The type for which to generate schema */ @SuppressWarnings("deprecation") public com.fasterxml.jackson.databind.jsonschema.JsonSchema generateJsonSchema(Class<?> type) throws JsonMappingException { if (type == null) { throw new IllegalArgumentException("A class must be provided"); } /* no need for embedded type information for JSON schema generation (all * type information it needs is accessible via "untyped" serializer) */ JsonSerializer<Object> ser = findValueSerializer(type, null); JsonNode schemaNode = (ser instanceof SchemaAware) ? ((SchemaAware) ser).getSchema(this, null) : com.fasterxml.jackson.databind.jsonschema.JsonSchema.getDefaultSchemaNode(); if (!(schemaNode instanceof ObjectNode)) { throw new IllegalArgumentException("Class " + type.getName() +" would not be serialized as a JSON object and therefore has no schema"); } return new com.fasterxml.jackson.databind.json

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>schema.JsonSchema((ObjectNode) schemaNode); } /** * The method to be called by {@link ObjectMapper} and {@link ObjectWriter} * to to expose the format of the given to to the given visitor * * @param javaType The type for which to generate format * @param visitor the visitor to accept the format */ public void acceptJsonFormatVisitor(JavaType javaType, JsonFormatVisitorWrapper visitor) throws JsonMappingException { if (javaType == null) { throw new IllegalArgumentException("A class must be provided"); } /* no need for embedded type information for JSON schema generation (all * type information it needs is accessible via "untyped" serializer) */ visitor.setProvider(this); findValueSerializer(javaType, null).acceptJsonFormatVisitor(visitor, javaType); } /** * Method that can be called to see if this serializer provider * can find a serializer for an instance of given class. *<p> * Note that no Exceptions are thrown, including unchecked ones: * implementations are to swallow exceptions if necessary. */ public boolean hasSerializerFor(Class<?> cls, AtomicReference<Throwable> cause) { try { JsonSerializer<?> ser = _findExplicitUntypedSerializer(cls); return (ser != null); } catch (JsonMappingException e) { if (cause != null) { cause.set(e); } } catch (RuntimeException e) { if (cause == null) { // earlier behavior throw e; } cause.set(e); } return false; } /* /******************************************************** /* Access to caching details /******************************************************** */ /** * Method that can be used to determine how many serializers this * provider is caching currently * (if it does caching: default implementation does) * Exact count depends on what kind of serializers get cached; * default implementation caches all serializers, including ones that * are eagerly constructed (for optimal access speed) *<p> * The main use case for this method is to allow conditional flushing of * serializer cache, if certain number of entries is reached. */ public int cachedSerializersCount() { return _serializerCache.size(); } /** * Method that will drop all serializers currently cached by this

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> provider. * This can be used to remove memory usage (in case some serializers are * only used once or so), or to force re-construction of serializers after * configuration changes for mapper than owns the provider. */ public void flushCachedSerializers() { _serializerCache.flush(); } /* /********************************************************** /* Object Id handling /********************************************************** */ @Override public WritableObjectId findObjectId(Object forPojo, ObjectIdGenerator<?> generatorType) { if (_seenObjectIds == null) { _seenObjectIds = _createObjectIdMap(); } else { WritableObjectId oid = _seenObjectIds.get(forPojo); if (oid != null) { return oid; } } // Not seen yet; must add an entry, return it. For that, we need generator ObjectIdGenerator<?> generator = null; if (_objectIdGenerators == null) { _objectIdGenerators = new ArrayList<ObjectIdGenerator<?>>(8); } else { for (int i = 0, len = _objectIdGenerators.size(); i < len; ++i) { ObjectIdGenerator<?> gen = _objectIdGenerators.get(i); if (gen.canUseFor(generatorType)) { generator = gen; break; } } } if (generator == null) { generator = generatorType.newForSerialization(this); _objectIdGenerators.add(generator); } WritableObjectId oid = new WritableObjectId(generator); _seenObjectIds.put(forPojo, oid); return oid; } /** * Overridable helper method used for creating {@link java.util.Map} * used for storing mappings from serializable objects to their * Object Ids. * * @since 2.3 */ protected Map<Object,WritableObjectId> _createObjectIdMap() { /* 06-Aug-2013, tatu: We may actually want to use equality, * instead of identity... so: */ if (isEnabled(SerializationFeature.USE_EQUALITY_FOR_OBJECT_ID)) { return new HashMap<Object,WritableObjectId>(); } return new IdentityHashMap<Object,WritableObjectId>(); } /* /********************************************************** /* Factory method impls

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> /********************************************************** */ @Override public JsonSerializer<Object> serializerInstance(Annotated annotated, Object serDef) throws JsonMappingException { if (serDef == null) { return null; } JsonSerializer<?> ser; if (serDef instanceof JsonSerializer) { ser = (JsonSerializer<?>) serDef; } else { /* Alas, there's no way to force return type of "either class * X or Y" -- need to throw an exception after the fact */ if (!(serDef instanceof Class)) { throw new IllegalStateException("AnnotationIntrospector returned serializer definition of type " +serDef.getClass().getName()+"; expected type JsonSerializer or Class<JsonSerializer> instead"); } Class<?> serClass = (Class<?>)serDef; // there are some known "no class" markers to consider too: if (serClass == JsonSerializer.None.class || ClassUtil.isBogusClass(serClass)) { return null; } if (!JsonSerializer.class.isAssignableFrom(serClass)) { throw new IllegalStateException("AnnotationIntrospector returned Class " +serClass.getName()+"; expected Class<JsonSerializer>"); } HandlerInstantiator hi = _config.getHandlerInstantiator(); ser = (hi == null) ? null : hi.serializerInstance(_config, annotated, serClass); if (ser == null) { ser = (JsonSerializer<?>) ClassUtil.createInstance(serClass, _config.canOverrideAccessModifiers()); } } return (JsonSerializer<Object>) _handleResolvable(ser); } /* /********************************************************** /* Helper classes /********************************************************** */ /** * Concrete implementation that defines factory method(s), * defined as final. */ public final static class Impl extends DefaultSerializerProvider { private static final long serialVersionUID = 1L; public Impl() { super(); } public Impl(Impl src) { super(src); } protected Impl(SerializerProvider src, SerializationConfig config,SerializerFactory f) { super(src, config, f); } @Override public DefaultSerializerProvider copy() { if (getClass() != Impl.class) { return super.copy(); } return new Impl(this); } @Override public Impl

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>.introspect(type); // Ok, so: can we find T(String) constructor? Constructor<?> ctor = beanDesc.findSingleArgConstructor(String.class); if (ctor != null) { if (config.canOverrideAccessModifiers()) { ClassUtil.checkAndFixAccess(ctor); } return new StdKeyDeserializer.StringCtorKeyDeserializer(ctor); } /* or if not, "static T valueOf(String)" (or equivalent marked * with @JsonCreator annotation?) */ Method m = beanDesc.findFactoryMethod(String.class); if (m != null){ if (config.canOverrideAccessModifiers()) { ClassUtil.checkAndFixAccess(m); } return new StdKeyDeserializer.StringFactoryKeyDeserializer(m); } // nope, no such luck... return null; } /* /********************************************************** /* KeyDeserializers implementation /********************************************************** */ @Override public KeyDeserializer findKeyDeserializer(JavaType type, DeserializationConfig config, BeanDescription beanDesc) throws JsonMappingException { Class<?> raw = type.getRawClass(); // 23-Apr-2013, tatu: Map primitive types, just in case one was given if (raw.isPrimitive()) { raw = ClassUtil.wrapperType(raw); } return StdKeyDeserializer.forType(raw); } }

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>package com.fasterxml.jackson.databind.ser.std; import java.io.IOException; import java.lang.reflect.Type; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Locale; import java.util.TimeZone; import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.introspect.Annotated; import com.fasterxml.jackson.databind.jsonFormatVisitors.*; import com.fasterxml.jackson.databind.ser.ContextualSerializer; import com.fasterxml.jackson.databind.util.StdDateFormat; @SuppressWarnings("serial") public abstract class DateTimeSerializerBase<T> extends StdScalarSerializer<T> implements ContextualSerializer { /** * Flag that indicates that serialization must be done as the * Java timestamp, regardless of other settings. */ protected final Boolean _useTimestamp; /** * Specific format to use, if not default format: non null value * also indicates that serialization is to be done as JSON String, * not numeric timestamp, unless {@link #_useTimestamp} is true. */ protected final DateFormat _customFormat; protected DateTimeSerializerBase(Class<T> type, Boolean useTimestamp, DateFormat customFormat) { super(type); _useTimestamp = useTimestamp; _customFormat = customFormat; } public abstract DateTimeSerializerBase<T> withFormat(Boolean timestamp, DateFormat customFormat); @Override public JsonSerializer<?> createContextual(SerializerProvider prov, BeanProperty property) throws JsonMappingException { if (property != null) { JsonFormat.Value format = prov.getAnnotationIntrospector().findFormat((Annotated)property.getMember()); if (format != null) { // Simple case first: serialize as numeric timestamp? if (format.getShape().isNumeric()) { return withFormat(Boolean.TRUE, null); } Boolean asNumber = (format.getShape() == JsonFormat.Shape.STRING) ? Boolean.FALSE : null;

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> // If not, do we have a pattern? TimeZone tz = format.getTimeZone(); if (format.hasPattern()) { String pattern = format.getPattern(); final Locale loc = format.hasLocale() ? format.getLocale() : prov.getLocale(); SimpleDateFormat df = new SimpleDateFormat(pattern, loc); if (tz == null) { tz = prov.getTimeZone(); } df.setTimeZone(tz); return withFormat(asNumber, df); } // If not, do we at least have a custom timezone? if (tz != null) { DateFormat df = prov.getConfig().getDateFormat(); // one shortcut: with our custom format, can simplify handling a bit if (df.getClass() == StdDateFormat.class) { final Locale loc = format.hasLocale() ? format.getLocale() : prov.getLocale(); df = StdDateFormat.getISO8601Format(tz, loc); } else { // otherwise need to clone, re-set timezone: df = (DateFormat) df.clone(); df.setTimeZone(tz); } return withFormat(asNumber, df); } } } return this; } /* /********************************************************** /* Accessors /********************************************************** */ @Override public boolean isEmpty(T value) { // let's assume "null date" (timestamp 0) qualifies for empty return (value == null) || (_timestamp(value) == 0L); } protected abstract long _timestamp(T value); @Override public JsonNode getSchema(SerializerProvider provider, Type typeHint) { //todo: (ryan) add a format for the date in the schema? return createSchemaNode(_asTimestamp(provider) ? "number" : "string", true); } @Override public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) throws JsonMappingException { _acceptJsonFormatVisitor(visitor, typeHint, _asTimestamp(visitor.getProvider())); } /* /********************************************************** /* Actual serialization /********************************************************** */ @Override public abstract void serialize(T value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonGenerationException; /* /********************************************************** /* Helper methods /

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>********************************************************** */ protected boolean _asTimestamp(SerializerProvider provider) { if (_useTimestamp != null) { return _useTimestamp.booleanValue(); } if (_customFormat == null) { if (provider != null) { return provider.isEnabled(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); } // 12-Jun-2014, tatu: Is it legal not to have provider? Was NPE:ing earlier so leave a check throw new IllegalArgumentException("Null 'provider' passed for "+handledType().getName()); } return false; } protected void _acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint, boolean asNumber) throws JsonMappingException { if (asNumber) { JsonIntegerFormatVisitor v2 = visitor.expectIntegerFormat(typeHint); if (v2 != null) { v2.numberType(JsonParser.NumberType.LONG); v2.format(JsonValueFormat.UTC_MILLISEC); } } else { JsonStringFormatVisitor v2 = visitor.expectStringFormat(typeHint); if (v2 != null) { v2.format(JsonValueFormat.DATE_TIME); } } } }

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>package com.fasterxml.jackson.databind.deser.std; import java.io.IOException; import java.util.*; import com.fasterxml.jackson.core.*; import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.deser.ContextualDeserializer; import com.fasterxml.jackson.databind.jsontype.TypeDeserializer; /** * Standard deserializer for {@link EnumSet}s. * <p> * Note: casting within this class is all messed up -- just could not figure out a way * to properly deal with recursive definition of "EnumSet<K extends Enum<K>, V> */ @SuppressWarnings("rawtypes") public class EnumSetDeserializer extends StdDeserializer<EnumSet<?>> implements ContextualDeserializer { private static final long serialVersionUID = 1L; // since 2.5 protected final JavaType _enumType; protected final Class<Enum> _enumClass; protected JsonDeserializer<Enum<?>> _enumDeserializer; /* /********************************************************** /* Life-cycle /********************************************************** */ @SuppressWarnings("unchecked" ) public EnumSetDeserializer(JavaType enumType, JsonDeserializer<?> deser) { super(EnumSet.class); _enumType = enumType; _enumClass = (Class<Enum>) enumType.getRawClass(); _enumDeserializer = (JsonDeserializer<Enum<?>>) deser; } public EnumSetDeserializer withDeserializer(JsonDeserializer<?> deser) { if (_enumDeserializer == deser) { return this; } return new EnumSetDeserializer(_enumType, deser); } /** * Because of costs associated with constructing Enum resolvers, * let's cache instances by default. */ @Override public boolean isCachable() { // One caveat: content deserializer should prevent caching if (_enumType.getValueHandler() != null) { return false; } return true; } @Override public JsonDeserializer<?> createContextual(DeserializationContext ctxt, BeanProperty property) throws JsonMappingException { JsonDeserializer<?> deser = _enumDeserializer; if (deser == null) { deser = ctxt.findContextualValueDeserializer(_enumType, property); } else { // if directly assigned, probably not yet contextual, so:

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> deser = ctxt.handleSecondaryContextualization(deser, property, _enumType); } return withDeserializer(deser); } /* /********************************************************** /* JsonDeserializer API /********************************************************** */ @SuppressWarnings("unchecked") @Override public EnumSet<?> deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { // Ok: must point to START_ARRAY (or equivalent) if (!jp.isExpectedStartArrayToken()) { throw ctxt.mappingException(EnumSet.class); } EnumSet result = constructSet(); JsonToken t; try { while ((t = jp.nextToken()) != JsonToken.END_ARRAY) { /* What to do with nulls? Fail or ignore? Fail, for now * (note: would fail if we passed it to EnumDeserializer, too, * but in general nulls should never be passed to non-container * deserializers) */ if (t == JsonToken.VALUE_NULL) { throw ctxt.mappingException(_enumClass); } Enum<?> value = _enumDeserializer.deserialize(jp, ctxt); /* 24-Mar-2012, tatu: As per [JACKSON-810], may actually get nulls; * but EnumSets don't allow nulls so need to skip. */ if (value != null) { result.add(value); } } } catch (Exception e) { throw JsonMappingException.wrapWithPath(e, result, result.size()); } return result; } @Override public Object deserializeWithType(JsonParser jp, DeserializationContext ctxt, TypeDeserializer typeDeserializer) throws IOException, JsonProcessingException { return typeDeserializer.deserializeTypedFromArray(jp, ctxt); } @SuppressWarnings("unchecked") private EnumSet constructSet() { // superbly ugly... but apparently necessary return EnumSet.noneOf(_enumClass); } }

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>package com.fasterxml.jackson.databind.ser.std; import java.io.IOException; import java.lang.reflect.Type; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.databind.JavaType; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.annotation.JacksonStdImpl; import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitorWrapper; /** * Serializer used for primitive boolean, as well as java.util.Boolean * wrapper type. *<p> * Since this is one of "native" types, no type information is ever * included on serialization (unlike for most scalar types as of 1.5) */ @JacksonStdImpl public final class BooleanSerializer extends NonTypedScalarSerializerBase<Boolean> { private static final long serialVersionUID = 1L; /** * Whether type serialized is primitive (boolean) or wrapper * (java.lang.Boolean); if true, former, if false, latter. */ protected final boolean _forPrimitive; public BooleanSerializer(boolean forPrimitive) { super(Boolean.class); _forPrimitive = forPrimitive; } @Override public void serialize(Boolean value, JsonGenerator jgen, SerializerProvider provider) throws IOException { jgen.writeBoolean(value.booleanValue()); } @Override public JsonNode getSchema(SerializerProvider provider, Type typeHint) { return createSchemaNode("boolean", !_forPrimitive); } @Override public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) throws JsonMappingException { if (visitor != null) { visitor.expectBooleanFormat(typeHint); } } }

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> shared (slow) cache /********************************************************** */ public synchronized int size() { return _sharedMap.size(); } /** * Method that checks if the shared (and hence, synchronized) lookup Map might have * untyped serializer for given type. */ public JsonSerializer<Object> untypedValueSerializer(Class<?> type) { synchronized (this) { return _sharedMap.get(new TypeKey(type, false)); } } public JsonSerializer<Object> untypedValueSerializer(JavaType type) { synchronized (this) { return _sharedMap.get(new TypeKey(type, false)); } } public JsonSerializer<Object> typedValueSerializer(JavaType type) { synchronized (this) { return _sharedMap.get(new TypeKey(type, true)); } } public JsonSerializer<Object> typedValueSerializer(Class<?> cls) { synchronized (this) { return _sharedMap.get(new TypeKey(cls, true)); } } /* /********************************************************** /* Methods for adding shared serializer instances /********************************************************** */ /** * Method called if none of lookups succeeded, and caller had to construct * a serializer. If so, we will update the shared lookup map so that it * can be resolved via it next time. */ public void addTypedSerializer(JavaType type, JsonSerializer<Object> ser) { synchronized (this) { if (_sharedMap.put(new TypeKey(type, true), ser) == null) { // let's invalidate the read-only copy, too, to get it updated _readOnlyMap = null; } } } public void addTypedSerializer(Class<?> cls, JsonSerializer<Object> ser) { synchronized (this) { if (_sharedMap.put(new TypeKey(cls, true), ser) == null) { // let's invalidate the read-only copy, too, to get it updated _readOnlyMap = null; } } } public void addAndResolveNonTypedSerializer(Class<?> type, JsonSerializer<Object> ser, SerializerProvider provider) throws JsonMappingException { synchronized (this) { if (_sharedMap.put(new TypeKey(type, false), ser) == null

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>) { // let's invalidate the read-only copy, too, to get it updated _readOnlyMap = null; } /* Finally: some serializers want to do post-processing, after * getting registered (to handle cyclic deps). */ /* 14-May-2011, tatu: As per [JACKSON-570], resolving needs to be done * in synchronized manner; this because while we do need to register * instance first, we also must keep lock until resolution is complete */ if (ser instanceof ResolvableSerializer) { ((ResolvableSerializer) ser).resolve(provider); } } } public void addAndResolveNonTypedSerializer(JavaType type, JsonSerializer<Object> ser, SerializerProvider provider) throws JsonMappingException { synchronized (this) { if (_sharedMap.put(new TypeKey(type, false), ser) == null) { // let's invalidate the read-only copy, too, to get it updated _readOnlyMap = null; } /* Finally: some serializers want to do post-processing, after * getting registered (to handle cyclic deps). */ /* 14-May-2011, tatu: As per [JACKSON-570], resolving needs to be done * in synchronized manner; this because while we do need to register * instance first, we also must keep lock until resolution is complete */ if (ser instanceof ResolvableSerializer) { ((ResolvableSerializer) ser).resolve(provider); } } } /** * Method called by StdSerializerProvider#flushCachedSerializers() to * clear all cached serializers */ public synchronized void flush() { _sharedMap.clear(); } /* /************************************************************** /* Helper class(es) /************************************************************** */ /** * Key that offers two "modes"; one with raw class, as used for * cases were raw class type is available (for example, when using * runtime type); and one with full generics-including. */ public final static class TypeKey { protected int _hashCode; protected Class<?> _class; protected JavaType _type; /** * Indicator of whether serializer stored has a type serializer * wrapper around it

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> not instances */ protected final static HashMap<String, Class<? extends JsonSerializer<?>>> _concreteLazy = new HashMap<String, Class<? extends JsonSerializer<?>>>(); static { /* String and string-like types (note: date types explicitly * not included -- can use either textual or numeric serialization) */ _concrete.put(String.class.getName(), new StringSerializer()); final ToStringSerializer sls = ToStringSerializer.instance; _concrete.put(StringBuffer.class.getName(), sls); _concrete.put(StringBuilder.class.getName(), sls); _concrete.put(Character.class.getName(), sls); _concrete.put(Character.TYPE.getName(), sls); // Primitives/wrappers for primitives (primitives needed for Beans) NumberSerializers.addAll(_concrete); _concrete.put(Boolean.TYPE.getName(), new BooleanSerializer(true)); _concrete.put(Boolean.class.getName(), new BooleanSerializer(false)); // Other numbers, more complicated _concrete.put(BigInteger.class.getName(), new NumberSerializer(BigInteger.class)); _concrete.put(BigDecimal.class.getName(),new NumberSerializer(BigDecimal.class)); // Other discrete non-container types: // First, Date/Time zoo: _concrete.put(Calendar.class.getName(), CalendarSerializer.instance); DateSerializer dateSer = DateSerializer.instance; _concrete.put(java.util.Date.class.getName(), dateSer); // note: timestamps are very similar to java.util.Date, thus serialized as such _concrete.put(java.sql.Timestamp.class.getName(), dateSer); // leave some of less commonly used ones as lazy, no point in proactive construction _concreteLazy.put(java.sql.Date.class.getName(), SqlDateSerializer.class); _concreteLazy.put(java.sql.Time.class.getName(), SqlTimeSerializer.class); // And then other standard non-structured JDK types for (Map.Entry<Class<?>,Object> en : StdJdkSerializers.all()) { Object value = en.getValue(); if (value instanceof JsonSerializer<?>) { _concrete.put(en.getKey().getName(), (JsonSerializer<?>) value); } else if (value instanceof Class<?

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>>) { @SuppressWarnings("unchecked") Class<? extends JsonSerializer<?>> cls = (Class<? extends JsonSerializer<?>>) value; _concreteLazy.put(en.getKey().getName(), cls); } else { // should never happen, but: throw new IllegalStateException("Internal error: unrecognized value of type "+en.getClass().getName()); } } // Jackson-specific type(s) // (Q: can this ever be sub-classed?) _concreteLazy.put(TokenBuffer.class.getName(), TokenBufferSerializer.class); } /* /********************************************************** /* Configuration /********************************************************** */ /** * Configuration settings for this factory; immutable instance (just like this * factory), new version created via copy-constructor (fluent-style) */ protected final SerializerFactoryConfig _factoryConfig; /* /********************************************************** /* Life cycle /********************************************************** */ /** * We will provide default constructor to allow sub-classing, * but make it protected so that no non-singleton instances of * the class will be instantiated. */ protected BasicSerializerFactory(SerializerFactoryConfig config) { _factoryConfig = (config == null) ? new SerializerFactoryConfig() : config; } /** * Method for getting current {@link SerializerFactoryConfig}. *<p> * Note that since instances are immutable, you can NOT change settings * by accessing an instance and calling methods: this will simply create * new instance of config object. */ public SerializerFactoryConfig getFactoryConfig() { return _factoryConfig; } /** * Method used for creating a new instance of this factory, but with different * configuration. Reason for specifying factory method (instead of plain constructor) * is to allow proper sub-classing of factories. *<p> * Note that custom sub-classes generally <b>must override</b> implementation * of this method, as it usually requires instantiating a new instance of * factory type. Check out javadocs for * {@link com.fasterxml.jackson.databind.ser.BeanSerializerFactory} for more details. */ public abstract SerializerFactory withConfig(SerializerFactoryConfig config); /** * Convenience method for creating a new factory instance with an additional * serializer provider. */ @Override public final SerializerFactory withAdditionalSerial

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>izers(Serializers additional) { return withConfig(_factoryConfig.withAdditionalSerializers(additional)); } /** * Convenience method for creating a new factory instance with an additional * key serializer provider. */ @Override public final SerializerFactory withAdditionalKeySerializers(Serializers additional) { return withConfig(_factoryConfig.withAdditionalKeySerializers(additional)); } /** * Convenience method for creating a new factory instance with additional bean * serializer modifier. */ @Override public final SerializerFactory withSerializerModifier(BeanSerializerModifier modifier) { return withConfig(_factoryConfig.withSerializerModifier(modifier)); } /* /********************************************************** /* SerializerFactory impl /********************************************************** */ // Implemented by sub-classes @Override public abstract JsonSerializer<Object> createSerializer(SerializerProvider prov, JavaType type) throws JsonMappingException; @Override @SuppressWarnings("unchecked") public JsonSerializer<Object> createKeySerializer(SerializationConfig config, JavaType keyType, JsonSerializer<Object> defaultImpl) { // We should not need any member method info; at most class annotations for Map type // ... at least, not here. BeanDescription beanDesc = config.introspectClassAnnotations(keyType.getRawClass()); JsonSerializer<?> ser = null; // Minor optimization: to avoid constructing beanDesc, bail out if none registered if (_factoryConfig.hasKeySerializers()) { // Only thing we have here are module-provided key serializers: for (Serializers serializers : _factoryConfig.keySerializers()) { ser = serializers.findSerializer(config, keyType, beanDesc); if (ser != null) { break; } } } if (ser == null) { ser = defaultImpl; if (ser == null) { ser = StdKeySerializers.getStdKeySerializer(config, keyType.getRawClass(), false); // As per [databind#47], also need to support @JsonValue if (ser == null) { beanDesc = config.introspect(keyType); AnnotatedMethod am = beanDesc.findJsonValueMethod(); if (am != null) { final Class<?> rawType = am.getRawReturnType(); JsonSerializer<?> delegate = StdKeySerializers.getStdKeySerializer(config, rawType,

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> { Class<?> raw = type.getRawClass(); String clsName = raw.getName(); JsonSerializer<?> ser = _concrete.get(clsName); if (ser == null) { Class<? extends JsonSerializer<?>> serClass = _concreteLazy.get(clsName); if (serClass != null) { try { return serClass.newInstance(); } catch (Exception e) { throw new IllegalStateException("Failed to instantiate standard serializer (of type "+serClass.getName()+"): " +e.getMessage(), e); } } } return ser; } /** * Method called to see if one of primary per-class annotations * (or related, like implementing of {@link JsonSerializable}) * determines the serializer to use. *<p> * Currently handles things like: *<ul> * <li>If type implements {@link JsonSerializable}, use that * </li> * <li>If type has {@link com.fasterxml.jackson.annotation.JsonValue} annotation (or equivalent), build serializer * based on that property * </li> *</ul> * * @since 2.0 */ protected final JsonSerializer<?> findSerializerByAnnotations(SerializerProvider prov, JavaType type, BeanDescription beanDesc) throws JsonMappingException { Class<?> raw = type.getRawClass(); // First: JsonSerializable? if (JsonSerializable.class.isAssignableFrom(raw)) { return SerializableSerializer.instance; } // Second: @JsonValue for any type AnnotatedMethod valueMethod = beanDesc.findJsonValueMethod(); if (valueMethod != null) { Method m = valueMethod.getAnnotated(); if (prov.canOverrideAccessModifiers()) { ClassUtil.checkAndFixAccess(m); } JsonSerializer<Object> ser = findSerializerFromAnnotation(prov, valueMethod); return new JsonValueSerializer(m, ser); } // No well-known annotations... return null; } /** * Method for checking if we can determine serializer to use based on set of * known primary types, checking for set of known base types (exact matches * having been compared against with <code>findSerializerByLookup</code>). * This does not include "secondary" interfaces, but * mostly concrete or abstract base

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> classes. */ protected final JsonSerializer<?> findSerializerByPrimaryType(SerializerProvider prov, JavaType type, BeanDescription beanDesc, boolean staticTyping) throws JsonMappingException { Class<?> raw = type.getRawClass(); // Then check for optional/external serializers [JACKSON-386] JsonSerializer<?> ser = findOptionalStdSerializer(prov, type, beanDesc, staticTyping); if (ser != null) { return ser; } if (Calendar.class.isAssignableFrom(raw)) { return CalendarSerializer.instance; } if (java.util.Date.class.isAssignableFrom(raw)) { return DateSerializer.instance; } if (Map.Entry.class.isAssignableFrom(raw)) { JavaType kt, vt; JavaType[] params = prov.getTypeFactory().findTypeParameters(type, Map.Entry.class); if (params == null || params.length != 2) { // assume that if we don't get 2, they are wrong... kt = vt = TypeFactory.unknownType(); } else { kt = params[0]; vt = params[1]; } return buildMapEntrySerializer(prov.getConfig(), type, beanDesc, staticTyping, kt, vt); } if (ByteBuffer.class.isAssignableFrom(raw)) { return new ByteBufferSerializer(); } if (InetAddress.class.isAssignableFrom(raw)) { return new InetAddressSerializer(); } if (InetSocketAddress.class.isAssignableFrom(raw)) { return new InetSocketAddressSerializer(); } if (TimeZone.class.isAssignableFrom(raw)) { return new TimeZoneSerializer(); } if (java.nio.charset.Charset.class.isAssignableFrom(raw)) { return ToStringSerializer.instance; } if (Number.class.isAssignableFrom(raw)) { // 21-May-2014, tatu: Couple of alternatives actually JsonFormat.Value format = beanDesc.findExpectedFormat(null); if (format != null) { switch (format.getShape()) { case STRING: return ToStringSerializer.instance; case OBJECT: // need to bail out to let it be serialized as POJO case ARRAY: // or, I guess ARRAY; otherwise no point in speculating return null; default:

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> } } return NumberSerializer.instance; } if (Enum.class.isAssignableFrom(raw)) { return buildEnumSerializer(prov.getConfig(), type, beanDesc); } return null; } /** * Overridable method called after checking all other types. * * @since 2.2 */ protected JsonSerializer<?> findOptionalStdSerializer(SerializerProvider prov, JavaType type, BeanDescription beanDesc, boolean staticTyping) throws JsonMappingException { return OptionalHandlerFactory.instance.findSerializer(prov.getConfig(), type, beanDesc); } /** * Reflection-based serialized find method, which checks if * given class implements one of recognized "add-on" interfaces. * Add-on here means a role that is usually or can be a secondary * trait: for example, * bean classes may implement {@link Iterable}, but their main * function is usually something else. The reason for */ protected final JsonSerializer<?> findSerializerByAddonType(SerializationConfig config, JavaType javaType, BeanDescription beanDesc, boolean staticTyping) throws JsonMappingException { Class<?> type = javaType.getRawClass(); if (Iterator.class.isAssignableFrom(type)) { JavaType[] params = config.getTypeFactory().findTypeParameters(javaType, Iterator.class); JavaType vt = (params == null || params.length != 1) ? TypeFactory.unknownType() : params[0]; return buildIteratorSerializer(config, javaType, beanDesc, staticTyping, vt); } if (Iterable.class.isAssignableFrom(type)) { JavaType[] params = config.getTypeFactory().findTypeParameters(javaType, Iterable.class); JavaType vt = (params == null || params.length != 1) ? TypeFactory.unknownType() : params[0]; return buildIterableSerializer(config, javaType, beanDesc, staticTyping, vt); } if (CharSequence.class.isAssignableFrom(type)) { return ToStringSerializer.instance; } return null; } /** * Helper method called to check if a class or method * has an annotation * (@link com.fasterxml.jackson.databind.annotation.JsonSerialize#using) * that tells the class to use for serialization. * Returns null if

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> no such annotation found. */ @SuppressWarnings("unchecked") protected JsonSerializer<Object> findSerializerFromAnnotation(SerializerProvider prov, Annotated a) throws JsonMappingException { Object serDef = prov.getAnnotationIntrospector().findSerializer(a); if (serDef == null) { return null; } JsonSerializer<Object> ser = prov.serializerInstance(a, serDef); // One more thing however: may need to also apply a converter: return (JsonSerializer<Object>) findConvertingSerializer(prov, a, ser); } /** * Helper method that will check whether given annotated entity (usually class, * but may also be a property accessor) indicates that a {@link Converter} is to * be used; and if so, to construct and return suitable serializer for it. * If not, will simply return given serializer as is. */ protected JsonSerializer<?> findConvertingSerializer(SerializerProvider prov, Annotated a, JsonSerializer<?> ser) throws JsonMappingException { Converter<Object,Object> conv = findConverter(prov, a); if (conv == null) { return ser; } JavaType delegateType = conv.getOutputType(prov.getTypeFactory()); return new StdDelegatingSerializer(conv, delegateType, ser); } protected Converter<Object,Object> findConverter(SerializerProvider prov, Annotated a) throws JsonMappingException { Object convDef = prov.getAnnotationIntrospector().findSerializationConverter(a); if (convDef == null) { return null; } return prov.converterInstance(a, convDef); } /* /********************************************************** /* Factory methods, container types: /********************************************************** */ /** * @since 2.1 */ protected JsonSerializer<?> buildContainerSerializer(SerializerProvider prov, JavaType type, BeanDescription beanDesc, boolean staticTyping) throws JsonMappingException { final SerializationConfig config = prov.getConfig(); /* [Issue#23], 15-Mar-2013, tatu: must force static handling of root value type, * with just one important exception: if value type is "untyped", let's * leave it as is; no clean way to make it work. */ if (!staticTyping && type

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>Type()) { return buildCollectionSerializer(config, (CollectionType) clt, beanDesc, staticTyping, elementTypeSerializer, elementValueSerializer); } CollectionLikeType clType = (CollectionLikeType) type; // Only custom variants for this: for (Serializers serializers : customSerializers()) { JsonSerializer<?> ser = serializers.findCollectionLikeSerializer(config, clType, beanDesc, elementTypeSerializer, elementValueSerializer); if (ser != null) { // [Issue#120]: Allow post-processing if (_factoryConfig.hasSerializerModifiers()) { for (BeanSerializerModifier mod : _factoryConfig.serializerModifiers()) { ser = mod.modifyCollectionLikeSerializer(config, clType, beanDesc, ser); } } return ser; } } // fall through either way (whether shape dictates serialization as POJO or not) return null; } if (type.isArrayType()) { return buildArraySerializer(config, (ArrayType) type, beanDesc, staticTyping, elementTypeSerializer, elementValueSerializer); } return null; } /** * Helper method that handles configuration details when constructing serializers for * {@link java.util.List} types that support efficient by-index access * * @since 2.1 */ protected JsonSerializer<?> buildCollectionSerializer(SerializationConfig config, CollectionType type, BeanDescription beanDesc, boolean staticTyping, TypeSerializer elementTypeSerializer, JsonSerializer<Object> elementValueSerializer) throws JsonMappingException { JsonSerializer<?> ser = null; // Module-provided custom collection serializers? for (Serializers serializers : customSerializers()) { ser = serializers.findCollectionSerializer(config, type, beanDesc, elementTypeSerializer, elementValueSerializer); if (ser != null) { break; } } if (ser == null) { // We may also want to use serialize Collections "as beans", if (and only if) // this is specified with `@JsonFormat(shape=Object)` JsonFormat.Value format = beanDesc.findExpectedFormat(null); if (format != null && format.getShape() == JsonFormat.Shape.OBJECT) { return null; } Class<?> raw = type.getRawClass(); if (Enum

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> TypeSerializer vts, JsonSerializer<Object> valueSerializer) { return new CollectionSerializer(elemType, staticTyping, vts, null, valueSerializer); } public JsonSerializer<?> buildEnumSetSerializer(JavaType enumType) { return new EnumSetSerializer(enumType, null); } /* /********************************************************** /* Factory methods, for Maps /********************************************************** */ /** * Helper method that handles configuration details when constructing serializers for * {@link java.util.Map} types. */ protected JsonSerializer<?> buildMapSerializer(SerializationConfig config, MapType type, BeanDescription beanDesc, boolean staticTyping, JsonSerializer<Object> keySerializer, TypeSerializer elementTypeSerializer, JsonSerializer<Object> elementValueSerializer) throws JsonMappingException { JsonSerializer<?> ser = null; for (Serializers serializers : customSerializers()) { ser = serializers.findMapSerializer(config, type, beanDesc, keySerializer, elementTypeSerializer, elementValueSerializer); if (ser != null) { break; } } if (ser == null) { // 08-Nov-2014, tatu: As per [databind#601], better just use default Map serializer /* if (EnumMap.class.isAssignableFrom(type.getRawClass()) && ((keySerializer == null) || ClassUtil.isJacksonStdImpl(keySerializer))) { JavaType keyType = type.getKeyType(); // Need to find key enum values... EnumValues enums = null; if (keyType.isEnumType()) { // non-enum if we got it as type erased class (from instance) @SuppressWarnings("unchecked") Class<Enum<?>> enumClass = (Class<Enum<?>>) keyType.getRawClass(); enums = EnumValues.construct(config, enumClass); } ser = new EnumMapSerializer(type.getContentType(), staticTyping, enums, elementTypeSerializer, elementValueSerializer); } else { */ Object filterId = findFilterId(config, beanDesc); MapSerializer mapSer = MapSerializer.construct(config.getAnnotationIntrospector().findPropertiesToIgnore(beanDesc.getClassInfo()), type, staticTyping, elementTypeSerializer, keySerializer, elementValueSerializer, filterId); Object suppressableValue = findSuppressableContentValue

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>(config, type.getContentType(), beanDesc); if (suppressableValue != null) { mapSer = mapSer.withContentInclusion(suppressableValue); } ser = mapSer; } // [Issue#120]: Allow post-processing if (_factoryConfig.hasSerializerModifiers()) { for (BeanSerializerModifier mod : _factoryConfig.serializerModifiers()) { ser = mod.modifyMapSerializer(config, type, beanDesc, ser); } } return ser; } /** * @since 2.5 */ protected Object findSuppressableContentValue(SerializationConfig config, JavaType contentType, BeanDescription beanDesc) throws JsonMappingException { JsonInclude.Include incl = beanDesc.findSerializationInclusionForContent(null); if (incl != null) { switch (incl) { case NON_DEFAULT: // 19-Oct-2014, tatu: Not sure what this'd mean; so take it to mean "NON_EMPTY"... incl = JsonInclude.Include.NON_EMPTY; break; default: // all other modes actually good as is, unless we'll find better ways break; } return incl; } return null; } /* /********************************************************** /* Factory methods, for Arrays /********************************************************** */ /** * Helper method that handles configuration details when constructing serializers for * <code>Object[]</code> (and subtypes, except for String). */ protected JsonSerializer<?> buildArraySerializer(SerializationConfig config, ArrayType type, BeanDescription beanDesc, boolean staticTyping, TypeSerializer elementTypeSerializer, JsonSerializer<Object> elementValueSerializer) throws JsonMappingException { JsonSerializer<?> ser = null; // Module-provided custom collection serializers? for (Serializers serializers : customSerializers()) { ser = serializers.findArraySerializer(config, type, beanDesc, elementTypeSerializer, elementValueSerializer); if (ser != null) { break; } } if (ser == null) { Class<?> raw = type.getRawClass(); // Important: do NOT use standard serializers if non-standard element value serializer specified if (elementValueSerializer == null || ClassUtil.isJacksonStdImpl(element

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>ValueSerializer)) { if (String[].class == raw) { ser = StringArraySerializer.instance; } else { // other standard types? ser = StdArraySerializers.findStandardImpl(raw); } } if (ser == null) { ser = new ObjectArraySerializer(type.getContentType(), staticTyping, elementTypeSerializer, elementValueSerializer); } } // [Issue#120]: Allow post-processing if (_factoryConfig.hasSerializerModifiers()) { for (BeanSerializerModifier mod : _factoryConfig.serializerModifiers()) { ser = mod.modifyArraySerializer(config, type, beanDesc, ser); } } return ser; } /* /********************************************************** /* Factory methods, for non-container types /********************************************************** */ /** * @since 2.5 */ protected JsonSerializer<?> buildIteratorSerializer(SerializationConfig config, JavaType type, BeanDescription beanDesc, boolean staticTyping, JavaType valueType) throws JsonMappingException { return new IteratorSerializer(valueType, staticTyping, createTypeSerializer(config, valueType), null); } @Deprecated // since 2.5 protected JsonSerializer<?> buildIteratorSerializer(SerializationConfig config, JavaType type, BeanDescription beanDesc, boolean staticTyping) throws JsonMappingException { JavaType[] params = config.getTypeFactory().findTypeParameters(type, Iterator.class); JavaType vt = (params == null || params.length != 1) ? TypeFactory.unknownType() : params[0]; return buildIteratorSerializer(config, type, beanDesc, staticTyping, vt); } /** * @since 2.5 */ protected JsonSerializer<?> buildIterableSerializer(SerializationConfig config, JavaType type, BeanDescription beanDesc, boolean staticTyping, JavaType valueType) throws JsonMappingException { return new IterableSerializer(valueType, staticTyping, createTypeSerializer(config, valueType), null); } @Deprecated // since 2.5 protected JsonSerializer<?> buildIterableSerializer(SerializationConfig config, JavaType type, BeanDescription beanDesc, boolean staticTyping) throws JsonMappingException { JavaType[] params = config.getTypeFactory().findTypeParameters(type, Iterable.class); JavaType vt =

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> (params == null || params.length != 1) ? TypeFactory.unknownType() : params[0]; return buildIterableSerializer(config, type, beanDesc, staticTyping, vt); } /** * @since 2.5 */ protected JsonSerializer<?> buildMapEntrySerializer(SerializationConfig config, JavaType type, BeanDescription beanDesc, boolean staticTyping, JavaType keyType, JavaType valueType) throws JsonMappingException { return new MapEntrySerializer(valueType, keyType, valueType, staticTyping, createTypeSerializer(config, valueType), null); } protected JsonSerializer<?> buildEnumSerializer(SerializationConfig config, JavaType type, BeanDescription beanDesc) throws JsonMappingException { /* As per [databind#24], may want to use alternate shape, serialize as JSON Object. * Challenge here is that EnumSerializer does not know how to produce * POJO style serialization, so we must handle that special case separately; * otherwise pass it to EnumSerializer. */ JsonFormat.Value format = beanDesc.findExpectedFormat(null); if (format != null && format.getShape() == JsonFormat.Shape.OBJECT) { // one special case: suppress serialization of "getDeclaringClass()"... ((BasicBeanDescription) beanDesc).removeProperty("declaringClass"); // returning null will mean that eventually BeanSerializer gets constructed return null; } @SuppressWarnings("unchecked") Class<Enum<?>> enumClass = (Class<Enum<?>>) type.getRawClass(); JsonSerializer<?> ser = EnumSerializer.construct(enumClass, config, beanDesc, format); // [Issue#120]: Allow post-processing if (_factoryConfig.hasSerializerModifiers()) { for (BeanSerializerModifier mod : _factoryConfig.serializerModifiers()) { ser = mod.modifyEnumSerializer(config, type, beanDesc, ser); } } return ser; } /* /********************************************************** /* Other helper methods /********************************************************** */ /** * Helper method used to encapsulate details of annotation-based type coercion */ @SuppressWarnings("unchecked") protected <T extends JavaType> T modifyTypeByAnnotation(SerializationConfig config, Annotated a, T type) { // first: let's check class for the instance

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> itself: Class<?> superclass = config.getAnnotationIntrospector().findSerializationType(a); if (superclass != null) { try { type = (T) type.widenBy(superclass); } catch (IllegalArgumentException iae) { throw new IllegalArgumentException("Failed to widen type "+type+" with concrete-type annotation (value "+superclass.getName()+"), method '"+a.getName()+"': "+iae.getMessage()); } } return modifySecondaryTypesByAnnotation(config, a, type); } @SuppressWarnings("unchecked") protected static <T extends JavaType> T modifySecondaryTypesByAnnotation(SerializationConfig config, Annotated a, T type) { AnnotationIntrospector intr = config.getAnnotationIntrospector(); // then key class if (type.isContainerType()) { Class<?> keyClass = intr.findSerializationKeyType(a, type.getKeyType()); if (keyClass != null) { // illegal to use on non-Maps if (!(type instanceof MapType)) { throw new IllegalArgumentException("Illegal key-type annotation: type "+type+" is not a Map type"); } try { type = (T) ((MapType) type).widenKey(keyClass); } catch (IllegalArgumentException iae) { throw new IllegalArgumentException("Failed to narrow key type "+type+" with key-type annotation ("+keyClass.getName()+"): "+iae.getMessage()); } } // and finally content class; only applicable to structured types Class<?> cc = intr.findSerializationContentType(a, type.getContentType()); if (cc != null) { try { type = (T) type.widenContentsBy(cc); } catch (IllegalArgumentException iae) { throw new IllegalArgumentException("Failed to narrow content type "+type+" with content-type annotation ("+cc.getName()+"): "+iae.getMessage()); } } } return type; } /** * Helper method called to try to find whether there is an annotation in the * class that indicates key serializer to use. * If so, will try to instantiate key serializer and return it; otherwise returns null. */ protected JsonSerializer<Object> _findKeySerializer(SerializerProvider prov, Annotated a) throws JsonMappingException { AnnotationIntrospector intr =

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> prov.getAnnotationIntrospector(); Object serDef = intr.findKeySerializer(a); if (serDef != null) { return prov.serializerInstance(a, serDef); } return null; } /** * Helper method called to try to find whether there is an annotation in the * class that indicates content ("value") serializer to use. * If so, will try to instantiate key serializer and return it; otherwise returns null. */ protected JsonSerializer<Object> _findContentSerializer(SerializerProvider prov, Annotated a) throws JsonMappingException { AnnotationIntrospector intr = prov.getAnnotationIntrospector(); Object serDef = intr.findContentSerializer(a); if (serDef != null) { return prov.serializerInstance(a, serDef); } return null; } /** * Method called to find filter that is configured to be used with bean * serializer being built, if any. */ protected Object findFilterId(SerializationConfig config, BeanDescription beanDesc) { return config.getAnnotationIntrospector().findFilterId((Annotated)beanDesc.getClassInfo()); } /** * Helper method to check whether global settings and/or class * annotations for the bean class indicate that static typing * (declared types) should be used for properties. * (instead of dynamic runtime types). * * @since 2.1 (earlier had variant with additional 'property' parameter) */ protected boolean usesStaticTyping(SerializationConfig config, BeanDescription beanDesc, TypeSerializer typeSer) { /* 16-Aug-2010, tatu: If there is a (value) type serializer, we can not force * static typing; that would make it impossible to handle expected subtypes */ if (typeSer != null) { return false; } AnnotationIntrospector intr = config.getAnnotationIntrospector(); JsonSerialize.Typing t = intr.findSerializationTyping(beanDesc.getClassInfo()); if (t != null && t != JsonSerialize.Typing.DEFAULT_TYPING) { return (t == JsonSerialize.Typing.STATIC); } return config.isEnabled(MapperFeature.USE_STATIC_TYPING); } protected Class<?> _verifyAsClass(Object src, String

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>package com.fasterxml.jackson.databind.deser; import com.fasterxml.jackson.databind.*; /** * Interface that defines API for simple extensions that can provide additional deserializers * for deserializer Map keys of various types, from JSON property names. * Access is by a single callback method; instance is to either return * a configured {@link KeyDeserializer} for specified type, or null to indicate that it * does not support handling of the type. In latter case, further calls can be made * for other providers; in former case returned key deserializer is used for handling of * key instances of specified type. */ public interface KeyDeserializers { public KeyDeserializer findKeyDeserializer(JavaType type, DeserializationConfig config, BeanDescription beanDesc) throws JsonMappingException; }

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>) { verifyNonDup(creator, C_PROPS, explicit); // [JACKSON-470] Better ensure we have no duplicate names either... if (properties.length > 1) { HashMap<String,Integer> names = new HashMap<String,Integer>(); for (int i = 0, len = properties.length; i < len; ++i) { String name = properties[i].getName(); /* [Issue-13]: Need to consider Injectables, which may not have * a name at all, and need to be skipped */ if (name.length() == 0 && properties[i].getInjectableValueId() != null) { continue; } Integer old = names.put(name, Integer.valueOf(i)); if (old != null) { throw new IllegalArgumentException("Duplicate creator property \""+name+"\" (index "+old+" vs "+i+")"); } } } _propertyBasedArgs = properties; } public void addIncompeteParameter(AnnotatedParameter parameter) { if (_incompleteParameter == null) { _incompleteParameter = parameter; } } // Bunch of methods deprecated in 2.5, to be removed from 2.6 or later @Deprecated // since 2.5 public void addStringCreator(AnnotatedWithParams creator) { addStringCreator(creator, false); } @Deprecated // since 2.5 public void addIntCreator(AnnotatedWithParams creator) { addBooleanCreator(creator, false); } @Deprecated // since 2.5 public void addLongCreator(AnnotatedWithParams creator) { addBooleanCreator(creator, false); } @Deprecated // since 2.5 public void addDoubleCreator(AnnotatedWithParams creator) { addBooleanCreator(creator, false); } @Deprecated // since 2.5 public void addBooleanCreator(AnnotatedWithParams creator) { addBooleanCreator(creator, false); } @Deprecated // since 2.5 public void addDelegatingCreator(AnnotatedWithParams creator, CreatorProperty[] injectables) { addDelegatingCreator(creator, false, injectables); } @Deprecated // since 2.5 public void addPropertyCreator(AnnotatedWithParams creator,

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> ctxt Deserialization context * @param propertyType Declared type of the value to deserializer (obtained using * 'setter' method signature and/or type annotations * * @throws JsonMappingException if there are fatal problems with * accessing suitable deserializer; including that of not * finding any serializer */ public JsonDeserializer<Object> findValueDeserializer(DeserializationContext ctxt, DeserializerFactory factory, JavaType propertyType) throws JsonMappingException { JsonDeserializer<Object> deser = _findCachedDeserializer(propertyType); if (deser == null) { // If not, need to request factory to construct (or recycle) deser = _createAndCacheValueDeserializer(ctxt, factory, propertyType); if (deser == null) { /* Should we let caller handle it? Let's have a helper method * decide it; can throw an exception, or return a valid * deserializer */ deser = _handleUnknownValueDeserializer(propertyType); } } return deser; } /** * Method called to get hold of a deserializer to use for deserializing * keys for {@link java.util.Map}. * * @throws JsonMappingException if there are fatal problems with * accessing suitable key deserializer; including that of not * finding any serializer */ public KeyDeserializer findKeyDeserializer(DeserializationContext ctxt, DeserializerFactory factory, JavaType type) throws JsonMappingException { KeyDeserializer kd = factory.createKeyDeserializer(ctxt, type); if (kd == null) { // if none found, need to use a placeholder that'll fail return _handleUnknownKeyDeserializer(type); } // First: need to resolve? if (kd instanceof ResolvableDeserializer) { ((ResolvableDeserializer) kd).resolve(ctxt); } return kd; } /** * Method called to find out whether provider would be able to find * a deserializer for given type, using a root reference (i.e. not * through fields or membership in an array or collection) */ public boolean hasValueDeserializerFor(DeserializationContext ctxt, DeserializerFactory factory, JavaType type) throws JsonMappingException { /* Note: mostly copied from findValueDeserializer, except for * handling of unknown types

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> */ JsonDeserializer<Object> deser = _findCachedDeserializer(type); if (deser == null) { deser = _createAndCacheValueDeserializer(ctxt, factory, type); } return (deser != null); } /* /********************************************************** /* Helper methods that handle cache lookups /********************************************************** */ protected JsonDeserializer<Object> _findCachedDeserializer(JavaType type) { if (type == null) { throw new IllegalArgumentException("Null JavaType passed"); } if (_hasCustomValueHandler(type)) { return null; } return _cachedDeserializers.get(type); } /** * Method that will try to create a deserializer for given type, * and resolve and cache it if necessary * * @param ctxt Currently active deserialization context * @param type Type of property to deserialize */ protected JsonDeserializer<Object> _createAndCacheValueDeserializer(DeserializationContext ctxt, DeserializerFactory factory, JavaType type) throws JsonMappingException { /* Only one thread to construct deserializers at any given point in time; * limitations necessary to ensure that only completely initialized ones * are visible and used. */ synchronized (_incompleteDeserializers) { // Ok, then: could it be that due to a race condition, deserializer can now be found? JsonDeserializer<Object> deser = _findCachedDeserializer(type); if (deser != null) { return deser; } int count = _incompleteDeserializers.size(); // Or perhaps being resolved right now? if (count > 0) { deser = _incompleteDeserializers.get(type); if (deser != null) { return deser; } } // Nope: need to create and possibly cache try { return _createAndCache2(ctxt, factory, type); } finally { // also: any deserializers that have been created are complete by now if (count == 0 && _incompleteDeserializers.size() > 0) { _incompleteDeserializers.clear(); } } } } /** * Method that handles actual construction (via factory) and caching (both * intermediate and eventual) */ protected JsonDeserializer<Object> _createAndCache2

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>(DeserializationContext ctxt, DeserializerFactory factory, JavaType type) throws JsonMappingException { JsonDeserializer<Object> deser; try { deser = _createDeserializer(ctxt, factory, type); } catch (IllegalArgumentException iae) { /* We better only expose checked exceptions, since those * are what caller is expected to handle */ throw new JsonMappingException(iae.getMessage(), null, iae); } if (deser == null) { return null; } /* cache resulting deserializer? always true for "plain" BeanDeserializer * (but can be re-defined for sub-classes by using @JsonCachable!) */ // 08-Jun-2010, tatu: Related to [JACKSON-296], need to avoid caching MapSerializers... so: boolean isResolvable = (deser instanceof ResolvableDeserializer); // 27-Mar-2015, tatu: As per [databind#735], avoid caching types with custom value desers boolean addToCache = !_hasCustomValueHandler(type) && deser.isCachable(); /* we will temporarily hold on to all created deserializers (to * handle cyclic references, and possibly reuse non-cached * deserializers (list, map)) */ /* 07-Jun-2010, tatu: Danger: [JACKSON-296] was caused by accidental * resolution of a reference -- couple of ways to prevent this; * either not add Lists or Maps, or clear references eagerly. * Let's actually do both; since both seem reasonable. */ /* Need to resolve? Mostly done for bean deserializers; required for * resolving cyclic references. */ if (isResolvable) { _incompleteDeserializers.put(type, deser); ((ResolvableDeserializer)deser).resolve(ctxt); _incompleteDeserializers.remove(type); } if (addToCache) { _cachedDeserializers.put(type, deser); } return deser; } /* /********************************************************** /* Helper methods for actual construction of deserializers /********************************************************** */ /** * Method that does the heavy lifting of checking for per-

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>type annotations, * find out full type, and figure out which actual factory method * to call. */ @SuppressWarnings("unchecked") protected JsonDeserializer<Object> _createDeserializer(DeserializationContext ctxt, DeserializerFactory factory, JavaType type) throws JsonMappingException { final DeserializationConfig config = ctxt.getConfig(); // First things first: do we need to use abstract type mapping? if (type.isAbstract() || type.isMapLikeType() || type.isCollectionLikeType()) { type = factory.mapAbstractType(config, type); } BeanDescription beanDesc; try { beanDesc = config.introspect(type); } catch (NoClassDefFoundError error) { return new NoClassDefFoundDeserializer<Object>(error); } // Then: does type define explicit deserializer to use, with annotation(s)? JsonDeserializer<Object> deser = findDeserializerFromAnnotation(ctxt, beanDesc.getClassInfo()); if (deser != null) { return deser; } // If not, may have further type-modification annotations to check: JavaType newType = modifyTypeByAnnotation(ctxt, beanDesc.getClassInfo(), type); if (newType != type) { type = newType; beanDesc = config.introspect(newType); } // We may also have a Builder type to consider... Class<?> builder = beanDesc.findPOJOBuilder(); if (builder != null) { return (JsonDeserializer<Object>) factory.createBuilderBasedDeserializer( ctxt, type, beanDesc, builder); } // Or perhaps a Converter? Converter<Object,Object> conv = beanDesc.findDeserializationConverter(); if (conv == null) { // nope, just construct in normal way return (JsonDeserializer<Object>) _createDeserializer2(ctxt, factory, type, beanDesc); } // otherwise need to do bit of introspection JavaType delegateType = conv.getInputType(ctxt.getTypeFactory()); // One more twist, as per [Issue#288]; probably need to get new BeanDesc if (!delegateType.hasRawClass(type.getRawClass())) { beanDesc = config.introspect(delegateType); } return new StdDelegatingDeserializer<Object>(conv

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>, delegateType, _createDeserializer2(ctxt, factory, delegateType, beanDesc)); } protected JsonDeserializer<?> _createDeserializer2(DeserializationContext ctxt, DeserializerFactory factory, JavaType type, BeanDescription beanDesc) throws JsonMappingException { final DeserializationConfig config = ctxt.getConfig(); // If not, let's see which factory method to use: if (type.isEnumType()) { return factory.createEnumDeserializer(ctxt, type, beanDesc); } if (type.isContainerType()) { if (type.isArrayType()) { return factory.createArrayDeserializer(ctxt, (ArrayType) type, beanDesc); } if (type.isMapLikeType()) { MapLikeType mlt = (MapLikeType) type; if (mlt.isTrueMapType()) { return factory.createMapDeserializer(ctxt,(MapType) mlt, beanDesc); } return factory.createMapLikeDeserializer(ctxt, mlt, beanDesc); } if (type.isCollectionLikeType()) { /* 03-Aug-2012, tatu: As per [Issue#40], one exception is if shape * is to be Shape.OBJECT. Ideally we'd determine it bit later on * (to allow custom handler checks), but that won't work for other * reasons. So do it here. */ JsonFormat.Value format = beanDesc.findExpectedFormat(null); if (format == null || format.getShape() != JsonFormat.Shape.OBJECT) { CollectionLikeType clt = (CollectionLikeType) type; if (clt.isTrueCollectionType()) { return factory.createCollectionDeserializer(ctxt, (CollectionType) clt, beanDesc); } return factory.createCollectionLikeDeserializer(ctxt, clt, beanDesc); } } } if (JsonNode.class.isAssignableFrom(type.getRawClass())) { return factory.createTreeDeserializer(config, type, beanDesc); } return factory.createBeanDeserializer(ctxt, type, beanDesc); } /** * Helper method called to check if a class or method * has annotation that tells which class to use for deserialization. * Returns null if no such annotation found. */

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> protected JsonDeserializer<Object> findDeserializerFromAnnotation(DeserializationContext ctxt, Annotated ann) throws JsonMappingException { Object deserDef = ctxt.getAnnotationIntrospector().findDeserializer(ann); if (deserDef == null) { return null; } JsonDeserializer<Object> deser = ctxt.deserializerInstance(ann, deserDef); // One more thing however: may need to also apply a converter: return findConvertingDeserializer(ctxt, ann, deser); } /** * Helper method that will check whether given annotated entity (usually class, * but may also be a property accessor) indicates that a {@link Converter} is to * be used; and if so, to construct and return suitable serializer for it. * If not, will simply return given serializer as is. */ protected JsonDeserializer<Object> findConvertingDeserializer(DeserializationContext ctxt, Annotated a, JsonDeserializer<Object> deser) throws JsonMappingException { Converter<Object,Object> conv = findConverter(ctxt, a); if (conv == null) { return deser; } JavaType delegateType = conv.getInputType(ctxt.getTypeFactory()); return (JsonDeserializer<Object>) new StdDelegatingDeserializer<Object>(conv, delegateType, deser); } protected Converter<Object,Object> findConverter(DeserializationContext ctxt, Annotated a) throws JsonMappingException { Object convDef = ctxt.getAnnotationIntrospector().findDeserializationConverter(a); if (convDef == null) { return null; } return ctxt.converterInstance(a, convDef); } /** * Method called to see if given method has annotations that indicate * a more specific type than what the argument specifies. * If annotations are present, they must specify compatible Class; * instance of which can be assigned using the method. This means * that the Class has to be raw class of type, or its sub-class * (or, implementing class if original Class instance is an interface). * * @param a Method or field that the type is associated with * @param type Type derived from the setter argument * * @return Original type if no annotations are present; or a more * specific type derived from it if type annotation(s) was found * *

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> @throws JsonMappingException if invalid annotation is found */ private JavaType modifyTypeByAnnotation(DeserializationContext ctxt, Annotated a, JavaType type) throws JsonMappingException { // first: let's check class for the instance itself: AnnotationIntrospector intr = ctxt.getAnnotationIntrospector(); Class<?> subclass = intr.findDeserializationType(a, type); if (subclass != null) { try { type = type.narrowBy(subclass); } catch (IllegalArgumentException iae) { throw new JsonMappingException("Failed to narrow type "+type+" with concrete-type annotation (value "+subclass.getName()+"), method '"+a.getName()+"': "+iae.getMessage(), null, iae); } } // then key class if (type.isContainerType()) { Class<?> keyClass = intr.findDeserializationKeyType(a, type.getKeyType()); if (keyClass != null) { // illegal to use on non-Maps if (!(type instanceof MapLikeType)) { throw new JsonMappingException("Illegal key-type annotation: type "+type+" is not a Map(-like) type"); } try { type = ((MapLikeType) type).narrowKey(keyClass); } catch (IllegalArgumentException iae) { throw new JsonMappingException("Failed to narrow key type "+type+" with key-type annotation ("+keyClass.getName()+"): "+iae.getMessage(), null, iae); } } JavaType keyType = type.getKeyType(); /* 21-Mar-2011, tatu: ... and associated deserializer too (unless already assigned) * (not 100% why or how, but this does seem to get called more than once, which * is not good: for now, let's just avoid errors) */ if (keyType != null && keyType.getValueHandler() == null) { Object kdDef = intr.findKeyDeserializer(a); if (kdDef != null) { KeyDeserializer kd = ctxt.keyDeserializerInstance(a, kdDef); if (kd != null) { type = ((MapLikeType) type).withKeyValueHandler(kd); keyType = type.getKeyType(); // just in case it's used below }

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> } } // and finally content class; only applicable to structured types Class<?> cc = intr.findDeserializationContentType(a, type.getContentType()); if (cc != null) { try { type = type.narrowContentsBy(cc); } catch (IllegalArgumentException iae) { throw new JsonMappingException("Failed to narrow content type "+type+" with content-type annotation ("+cc.getName()+"): "+iae.getMessage(), null, iae); } } // ... as well as deserializer for contents: JavaType contentType = type.getContentType(); if (contentType.getValueHandler() == null) { // as with above, avoid resetting (which would trigger exception) Object cdDef = intr.findContentDeserializer(a); if (cdDef != null) { JsonDeserializer<?> cd = null; if (cdDef instanceof JsonDeserializer<?>) { cdDef = (JsonDeserializer<?>) cdDef; } else { Class<?> cdClass = _verifyAsClass(cdDef, "findContentDeserializer", JsonDeserializer.None.class); if (cdClass != null) { cd = ctxt.deserializerInstance(a, cdClass); } } if (cd != null) { type = type.withContentValueHandler(cd); } } } } return type; } /* /********************************************************** /* Helper methods, other /********************************************************** */ /** * Helper method used to prevent both caching and cache lookups for structured * types that have custom value handlers * * @since 2.4.6 */ private boolean _hasCustomValueHandler(JavaType t) { if (t.isContainerType()) { JavaType ct = t.getContentType(); return (ct != null) && (ct.getValueHandler() != null); } return false; } private Class<?> _verifyAsClass(Object src, String methodName, Class<?> noneClass) { if (src == null) { return null; } if (!(src instanceof Class)) { throw new IllegalStateException("AnnotationIntrospector."+methodName+"() returned value of type "+src.getClass().getName()+": expected type JsonSerializer or Class<JsonSerializer> instead"); } Class<?> cls = (Class<?>) src; if

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> (cls == noneClass || ClassUtil.isBogusClass(cls)) { return null; } return cls; } /* /********************************************************** /* Overridable error reporting methods /********************************************************** */ protected JsonDeserializer<Object> _handleUnknownValueDeserializer(JavaType type) throws JsonMappingException { /* Let's try to figure out the reason, to give better error * messages */ Class<?> rawClass = type.getRawClass(); if (!ClassUtil.isConcrete(rawClass)) { throw new JsonMappingException("Can not find a Value deserializer for abstract type "+type); } throw new JsonMappingException("Can not find a Value deserializer for type "+type); } protected KeyDeserializer _handleUnknownKeyDeserializer(JavaType type) throws JsonMappingException { throw new JsonMappingException("Can not find a (Map) Key deserializer for type "+type); } }

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>SuppressWarnings("unchecked") public StdDelegatingSerializer(Converter<Object,?> converter, JavaType delegateType, JsonSerializer<?> delegateSerializer) { super(delegateType); _converter = converter; _delegateType = delegateType; _delegateSerializer = (JsonSerializer<Object>) delegateSerializer; } /** * Method used for creating resolved contextual instances. Must be * overridden when sub-classing. */ protected StdDelegatingSerializer withDelegate(Converter<Object,?> converter, JavaType delegateType, JsonSerializer<?> delegateSerializer) { if (getClass() != StdDelegatingSerializer.class) { throw new IllegalStateException("Sub-class "+getClass().getName()+" must override 'withDelegate'"); } return new StdDelegatingSerializer(converter, delegateType, delegateSerializer); } /* /********************************************************** /* Contextualization /********************************************************** */ @Override public void resolve(SerializerProvider provider) throws JsonMappingException { if ((_delegateSerializer != null) && (_delegateSerializer instanceof ResolvableSerializer)) { ((ResolvableSerializer) _delegateSerializer).resolve(provider); } } @Override public JsonSerializer<?> createContextual(SerializerProvider provider, BeanProperty property) throws JsonMappingException { JsonSerializer<?> delSer = _delegateSerializer; JavaType delegateType = _delegateType; if (delSer == null) { // Otherwise, need to locate serializer to delegate to. For that we need type information... if (delegateType == null) { delegateType = _converter.getOutputType(provider.getTypeFactory()); } delSer = provider.findValueSerializer(delegateType); } if (delSer instanceof ContextualSerializer) { delSer = provider.handleSecondaryContextualization(delSer, property); } return (delSer == _delegateSerializer) ? this : withDelegate(_converter, delegateType, delSer); } /* /********************************************************** /* Accessors /********************************************************** */ protected Converter<Object, ?> getConverter() { return _converter; } @Override public JsonSerializer<?> getDelegatee() { return _delegateSerializer; } /* /********************************************************** /* Serialization /********************************************************** */ @Override public void serialize(Object value, JsonGenerator gen, SerializerProvider provider) throws IOException { Object

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> delegateValue = convertValue(value); // should we accept nulls? if (delegateValue == null) { provider.defaultSerializeNull(gen); return; } _delegateSerializer.serialize(delegateValue, gen, provider); } @Override public void serializeWithType(Object value, JsonGenerator gen, SerializerProvider provider, TypeSerializer typeSer) throws IOException { /* 03-Oct-2012, tatu: This is actually unlikely to work ok... but for now, * let's give it a chance? */ Object delegateValue = convertValue(value); _delegateSerializer.serializeWithType(delegateValue, gen, provider, typeSer); } @Override @Deprecated // since 1.5 public boolean isEmpty(Object value) { Object delegateValue = convertValue(value); return _delegateSerializer.isEmpty(delegateValue); } @Override public boolean isEmpty(SerializerProvider prov, Object value) { Object delegateValue = convertValue(value); return _delegateSerializer.isEmpty(prov, delegateValue); } /* /********************************************************** /* Schema functionality /********************************************************** */ @Override public JsonNode getSchema(SerializerProvider provider, Type typeHint) throws JsonMappingException { if (_delegateSerializer instanceof SchemaAware) { return ((SchemaAware) _delegateSerializer).getSchema(provider, typeHint); } return super.getSchema(provider, typeHint); } @Override public JsonNode getSchema(SerializerProvider provider, Type typeHint, boolean isOptional) throws JsonMappingException { if (_delegateSerializer instanceof SchemaAware) { return ((SchemaAware) _delegateSerializer).getSchema(provider, typeHint, isOptional); } return super.getSchema(provider, typeHint); } @Override public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) throws JsonMappingException { /* 03-Sep-2012, tatu: Not sure if this can be made to really work * properly... but for now, try this: */ _delegateSerializer.acceptJsonFormatVisitor(visitor, typeHint); } /* /********************************************************** /* Overridable methods /********************************************************** */ /** * Method called to convert

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> keyType = mapType.getKeyType(); valueType = mapType.getContentType(); } // If value type is final, it's same as forcing static value typing: if (!staticValueType) { staticValueType = (valueType != null && valueType.isFinal()); } else { // also: Object.class can not be handled as static, ever if (valueType.getRawClass() == Object.class) { staticValueType = false; } } MapSerializer ser = new MapSerializer(ignoredEntries, keyType, valueType, staticValueType, vts, keySerializer, valueSerializer); if (filterId != null) { ser = ser.withFilterId(filterId); } return ser; } /* /********************************************************** /* Post-processing (contextualization) /********************************************************** */ @Override public JsonSerializer<?> createContextual(SerializerProvider provider, BeanProperty property) throws JsonMappingException { /* 29-Sep-2012, tatu: Actually, we need to do much more contextual * checking here since we finally know for sure the property, * and it may have overrides */ JsonSerializer<?> ser = null; JsonSerializer<?> keySer = null; final AnnotationIntrospector intr = provider.getAnnotationIntrospector(); final AnnotatedMember propertyAcc = (property == null) ? null : property.getMember(); Object suppressableValue = _suppressableValue; // First: if we have a property, may have property-annotation overrides if (propertyAcc != null && intr != null) { Object serDef = intr.findKeySerializer(propertyAcc); if (serDef != null) { keySer = provider.serializerInstance(propertyAcc, serDef); } serDef = intr.findContentSerializer(propertyAcc); if (serDef != null) { ser = provider.serializerInstance(propertyAcc, serDef); } JsonInclude.Include incl = intr.findSerializationInclusionForContent(propertyAcc, null); if (incl != null) { suppressableValue = incl; } } if (ser == null) { ser = _valueSerializer; } // [Issue#124]: May have a content converter ser = findConvertingContent

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>For(cc); if (valueSer == null) { if (_valueType.hasGenericTypes()) { valueSer = _findAndAddDynamic(serializers, provider.constructSpecializedType(_valueType, cc), provider); } else { valueSer = _findAndAddDynamic(serializers, cc, provider); } serializers = _dynamicValueSerializers; } // also may need to skip non-empty values: if ((suppressableValue == JsonInclude.Include.NON_EMPTY) && valueSer.isEmpty(provider, valueElem)) { continue; } } keySerializer.serialize(keyElem, gen, provider); try { valueSer.serializeWithType(valueElem, gen, provider, _valueTypeSerializer); } catch (Exception e) { String keyDesc = ""+keyElem; wrapAndThrow(provider, e, value, keyDesc); } } } @Deprecated // since 2.5 protected void serializeTypedFields(Map<?,?> value, JsonGenerator gen, SerializerProvider provider) throws IOException { serializeTypedFields(value, gen, provider, provider.isEnabled(SerializationFeature.WRITE_NULL_MAP_VALUES) ? null : JsonInclude.Include.NON_NULL); } /* /********************************************************** /* Schema related functionality /********************************************************** */ @Override public JsonNode getSchema(SerializerProvider provider, Type typeHint) { ObjectNode o = createSchemaNode("object", true); //(ryan) even though it's possible to statically determine the "value" type of the map, // there's no way to statically determine the keys, so the "Entries" can't be determined. return o; } @Override public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) throws JsonMappingException { JsonMapFormatVisitor v2 = (visitor == null) ? null : visitor.expectMapFormat(typeHint); if (v2 != null) { v2.keyFormat(_keySerializer, _keyType); JsonSerializer<?> valueSer = _valueSerializer; if (valueSer == null) { valueSer = _findAndAddDynamic(_dynamicValueSerializers, _valueType, visitor.getProvider()); } v2.valueFormat(valueSer

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>, _valueType); } } /* /********************************************************** /* Internal helper methods /********************************************************** */ protected final JsonSerializer<Object> _findAndAddDynamic(PropertySerializerMap map, Class<?> type, SerializerProvider provider) throws JsonMappingException { PropertySerializerMap.SerializerAndMapResult result = map.findAndAddSecondarySerializer(type, provider, _property); // did we get a new map of serializers? If so, start using it if (map != result.map) { _dynamicValueSerializers = result.map; } return result.serializer; } protected final JsonSerializer<Object> _findAndAddDynamic(PropertySerializerMap map, JavaType type, SerializerProvider provider) throws JsonMappingException { PropertySerializerMap.SerializerAndMapResult result = map.findAndAddSecondarySerializer(type, provider, _property); if (map != result.map) { _dynamicValueSerializers = result.map; } return result.serializer; } protected Map<?,?> _orderEntries(Map<?,?> input) { // minor optimization: may already be sorted? if (input instanceof SortedMap<?,?>) { return input; } return new TreeMap<Object,Object>(input); } }

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>package com.fasterxml.jackson.databind.ser.std; import java.io.IOException; import java.lang.reflect.Type; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.databind.JavaType; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.annotation.JacksonStdImpl; import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitorWrapper; import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonStringFormatVisitor; import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonValueFormat; @JacksonStdImpl @SuppressWarnings("serial") public class SqlTimeSerializer extends StdScalarSerializer<java.sql.Time> { public SqlTimeSerializer() { super(java.sql.Time.class); } @Override public void serialize(java.sql.Time value, JsonGenerator jgen, SerializerProvider provider) throws IOException { jgen.writeString(value.toString()); } @Override public JsonNode getSchema(SerializerProvider provider, Type typeHint) { return createSchemaNode("string", true); } @Override public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) throws JsonMappingException { JsonStringFormatVisitor v2 = (visitor == null) ? null : visitor.expectStringFormat(typeHint); if (v2 != null) { v2.format(JsonValueFormat.DATE_TIME); } } }

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> } protected final boolean _isPosInf(String text) { return "Infinity".equals(text) || "INF".equals(text); } protected final boolean _isNaN(String text) { return "NaN".equals(text); } /* /**************************************************** /* Helper methods for sub-classes, resolving dependencies /**************************************************** */ /** * Helper method used to locate deserializers for properties the * type this deserializer handles contains (usually for properties of * bean types) * * @param type Type of property to deserialize * @param property Actual property object (field, method, constuctor parameter) used * for passing deserialized values; provided so deserializer can be contextualized if necessary (since 1.7) */ protected JsonDeserializer<Object> findDeserializer(DeserializationContext ctxt, JavaType type, BeanProperty property) throws JsonMappingException { return ctxt.findContextualValueDeserializer(type, property); } /* /********************************************************** /* Helper methods for sub-classes, deserializer construction /********************************************************** */ /** * Helper method that can be used to see if specified property has annotation * indicating that a converter is to be used for contained values (contents * of structured types; array/List/Map values) * * @param existingDeserializer (optional) configured content * serializer if one already exists. * * @since 2.2 */ protected JsonDeserializer<?> findConvertingContentDeserializer(DeserializationContext ctxt, BeanProperty prop, JsonDeserializer<?> existingDeserializer) throws JsonMappingException { final AnnotationIntrospector intr = ctxt.getAnnotationIntrospector(); if (intr != null && prop != null) { AnnotatedMember member = prop.getMember(); if (member != null) { Object convDef = intr.findDeserializationContentConverter(member); if (convDef != null) { Converter<Object,Object> conv = ctxt.converterInstance(prop.getMember(), convDef); JavaType delegateType = conv.getInputType(ctxt.getTypeFactory()); if (existingDeserializer == null) { existingDeserializer = ctxt.findContextualValueDeserializer(delegateType, prop); } return new StdDelegatingDeserializer<Object>(conv, delegateType, existingDeserializer); } } } return existing

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>CompletedChunk(chunk); ix = 0; } chunk[ix++] = value; } } catch (Exception e) { throw JsonMappingException.wrapWithPath(e, chunk, buffer.bufferedSize() + ix); } String[] result = buffer.completeAndClearBuffer(chunk, ix, String.class); ctxt.returnObjectBuffer(buffer); return result; } /** * Offlined version used when we do not use the default deserialization method. */ protected final String[] _deserializeCustom(JsonParser jp, DeserializationContext ctxt) throws IOException { final ObjectBuffer buffer = ctxt.leaseObjectBuffer(); Object[] chunk = buffer.resetAndStart(); final JsonDeserializer<String> deser = _elementDeserializer; int ix = 0; try { while (true) { /* 30-Dec-2014, tatu: This may look odd, but let's actually call method * that suggest we are expecting a String; this helps with some formats, * notably XML. Note, however, that while we can get String, we can't * assume that's what we use due to custom deserializer */ String value; if (jp.nextTextValue() == null) { JsonToken t = jp.getCurrentToken(); if (t == JsonToken.END_ARRAY) { break; } // Ok: no need to convert Strings, but must recognize nulls value = (t == JsonToken.VALUE_NULL) ? deser.getNullValue() : deser.deserialize(jp, ctxt); } else { value = deser.deserialize(jp, ctxt); } if (ix >= chunk.length) { chunk = buffer.appendCompletedChunk(chunk); ix = 0; } chunk[ix++] = value; } } catch (Exception e) { // note: pass String.class, not String[].class, as we need element type for error info throw JsonMappingException.wrapWithPath(e, String.class, ix); } String[] result = buffer.completeAndClearBuffer(chunk, ix, String.class); ctxt.returnObjectBuffer(buffer); return result; } @Override public Object deserializeWithType(JsonParser jp, Deserial

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>izationContext ctxt, TypeDeserializer typeDeserializer) throws IOException { return typeDeserializer.deserializeTypedFromArray(jp, ctxt); } private final String[] handleNonArray(JsonParser jp, DeserializationContext ctxt) throws IOException { // [JACKSON-526]: implicit arrays from single values? if (!ctxt.isEnabled(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY)) { // [JACKSON-620] Empty String can become null... if ((jp.getCurrentToken() == JsonToken.VALUE_STRING) && ctxt.isEnabled(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT)) { String str = jp.getText(); if (str.length() == 0) { return null; } } throw ctxt.mappingException(_valueClass); } return new String[] { (jp.getCurrentToken() == JsonToken.VALUE_NULL) ? null : _parseString(jp, ctxt) }; } /** * Contextualization is needed to see whether we can "inline" deserialization * of String values, or if we have to use separate value deserializer. */ @Override public JsonDeserializer<?> createContextual(DeserializationContext ctxt, BeanProperty property) throws JsonMappingException { JsonDeserializer<?> deser = _elementDeserializer; // #125: May have a content converter deser = findConvertingContentDeserializer(ctxt, property, deser); JavaType type = ctxt.constructType(String.class); if (deser == null) { deser = ctxt.findContextualValueDeserializer(type, property); } else { // if directly assigned, probably not yet contextual, so: deser = ctxt.handleSecondaryContextualization(deser, property, type); } // Ok ok: if all we got is the default String deserializer, can just forget about it if (deser != null && this.isDefaultDeserializer(deser)) { deser = null; } if (_elementDeserializer != deser) { return new StringArrayDeserializer(deser); } return this; } }

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> return UNBOUND; } // ... so this piece of code should not be needed any more /* Package pkg = enclosing.getPackage(); if (pkg != null) { // as per [JACKSON-533], also include "java.util.concurrent": if (pkg.getName().startsWith("java.util")) { return UNBOUND; } } */ } } if (!mustFind) { return null; } String className; if (_contextClass != null) { className = _contextClass.getName(); } else if (_contextType != null) { className = _contextType.toString(); } else { className = "UNKNOWN"; } throw new IllegalArgumentException("Type variable '"+name +"' can not be resolved (with context of class "+className+")"); //t = UNBOUND; } public void addBinding(String name, JavaType type) { // note: emptyMap() is unmodifiable, hence second check is needed: if (_bindings == null || _bindings.size() == 0) { _bindings = new LinkedHashMap<String,JavaType>(); } _bindings.put(name, type); } public JavaType[] typesAsArray() { if (_bindings == null) { _resolve(); } if (_bindings.size() == 0) { return NO_TYPES; } return _bindings.values().toArray(new JavaType[_bindings.size()]); } /* /********************************************************** /* Internal methods /********************************************************** */ protected void _resolve() { _resolveBindings(_contextClass); // finally: may have root level type info too if (_contextType != null) { int count = _contextType.containedTypeCount(); if (count > 0) { for (int i = 0; i < count; ++i) { String name = _contextType.containedTypeName(i); JavaType type = _contextType.containedType(i); addBinding(name, type); } } } // nothing bound? mark with empty map to prevent further calls if (_bindings == null) { _bindings = Collections.emptyMap(); } } public void _addPlaceholder(String name) {

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> if (_placeholders == null) { _placeholders = new HashSet<String>(); } _placeholders.add(name); } protected void _resolveBindings(Type t) { if (t == null) return; Class<?> raw; if (t instanceof ParameterizedType) { ParameterizedType pt = (ParameterizedType) t; Type[] args = pt.getActualTypeArguments(); if (args != null && args.length > 0) { Class<?> rawType = (Class<?>) pt.getRawType(); TypeVariable<?>[] vars = rawType.getTypeParameters(); if (vars.length != args.length) { throw new IllegalArgumentException("Strange parametrized type (in class "+rawType.getName()+"): number of type arguments != number of type parameters ("+args.length+" vs "+vars.length+")"); } for (int i = 0, len = args.length; i < len; ++i) { TypeVariable<?> var = vars[i]; String name = var.getName(); if (_bindings == null) { _bindings = new LinkedHashMap<String,JavaType>(); } else { /* 24-Mar-2010, tatu: Better ensure that we do not overwrite something * collected earlier (since we descend towards super-classes): */ if (_bindings.containsKey(name)) continue; } // first: add a placeholder to prevent infinite loops _addPlaceholder(name); // then resolve type _bindings.put(name, _typeFactory._constructType(args[i], this)); } } raw = (Class<?>)pt.getRawType(); } else if (t instanceof Class<?>) { raw = (Class<?>) t; /* [JACKSON-677]: If this is an inner class then the generics are defined on the * enclosing class so we have to check there as well. We don't * need to call getEnclosingClass since anonymous classes declare * generics */ Class<?> decl = raw.getDeclaringClass(); /* 08-Feb-2013, tatu: Except that if context is also super-class, we must * skip it; context will be checked anyway, and we'd get Stack

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>Overflow if * we went there. */ if (decl != null && !decl.isAssignableFrom(raw)) { _resolveBindings(raw.getDeclaringClass()); } /* 24-Mar-2010, tatu: Can not have true generics definitions, but can * have lower bounds ("<T extends BeanBase>") in declaration itself */ TypeVariable<?>[] vars = raw.getTypeParameters(); if (vars != null && vars.length > 0) { JavaType[] typeParams = null; if (_contextType != null && raw.isAssignableFrom(_contextType.getRawClass())) { typeParams = _typeFactory.findTypeParameters(_contextType, raw); } for (int i = 0; i < vars.length; i++) { TypeVariable<?> var = vars[i]; String name = var.getName(); Type varType = var.getBounds()[0]; if (varType != null) { if (_bindings == null) { _bindings = new LinkedHashMap<String,JavaType>(); } else { // and no overwriting... if (_bindings.containsKey(name)) continue; } _addPlaceholder(name); // to prevent infinite loops if (typeParams != null && typeParams.length > i) { _bindings.put(name, typeParams[i]); } else { _bindings.put(name, _typeFactory._constructType(varType, this)); } } } } } else { // probably can't be any of these... so let's skip for now //if (type instanceof GenericArrayType) { //if (type instanceof TypeVariable<?>) { // if (type instanceof WildcardType) { return; } // but even if it's not a parameterized type, its super types may be: _resolveBindings(raw.getGenericSuperclass()); for (Type intType : raw.getGenericInterfaces()) { _resolveBindings(intType); } } @Override public String toString() { if (_bindings == null) { _resolve(); } StringBuilder sb = new StringBuilder("[TypeBindings for "); if (_contextType != null) { sb.append(_contextType.toString()); } else { sb.append(_contextClass

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>Instantiator = valueInstantiator; _delegateDeserializer = (JsonDeserializer<Object>) delegateDeser; } protected StringCollectionDeserializer withResolved(JsonDeserializer<?> delegateDeser, JsonDeserializer<?> valueDeser) { if ((_valueDeserializer == valueDeser) && (_delegateDeserializer == delegateDeser)) { return this; } return new StringCollectionDeserializer(_collectionType, _valueInstantiator, delegateDeser, valueDeser); } @Override // since 2.5 public boolean isCachable() { // 26-Mar-2015, tatu: Important: prevent caching if custom deserializers are involved return (_valueDeserializer == null) && (_delegateDeserializer == null); } /* /********************************************************** /* Validation, post-processing /********************************************************** */ @Override public JsonDeserializer<?> createContextual(DeserializationContext ctxt, BeanProperty property) throws JsonMappingException { // May need to resolve types for delegate-based creators: JsonDeserializer<Object> delegate = null; if (_valueInstantiator != null) { AnnotatedWithParams delegateCreator = _valueInstantiator.getDelegateCreator(); if (delegateCreator != null) { JavaType delegateType = _valueInstantiator.getDelegateType(ctxt.getConfig()); delegate = findDeserializer(ctxt, delegateType, property); } } JsonDeserializer<?> valueDeser = _valueDeserializer; final JavaType valueType = _collectionType.getContentType(); if (valueDeser == null) { // #125: May have a content converter valueDeser = findConvertingContentDeserializer(ctxt, property, valueDeser); if (valueDeser == null) { // And we may also need to get deserializer for String valueDeser = ctxt.findContextualValueDeserializer(valueType, property); } } else { // if directly assigned, probably not yet contextual, so: valueDeser = ctxt.handleSecondaryContextualization(valueDeser, property, valueType); } if (isDefaultDeserializer(valueDeser)) { valueDeser = null; } return withResolved(delegate, valueDeser); } /* /********************************************************** /* ContainerDeserializerBase API /********************************************************** */ @

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>Override public JavaType getContentType() { return _collectionType.getContentType(); } @SuppressWarnings("unchecked") @Override public JsonDeserializer<Object> getContentDeserializer() { JsonDeserializer<?> deser = _valueDeserializer; return (JsonDeserializer<Object>) deser; } /* /********************************************************** /* JsonDeserializer API /********************************************************** */ @SuppressWarnings("unchecked") @Override public Collection<String> deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException { if (_delegateDeserializer != null) { return (Collection<String>) _valueInstantiator.createUsingDelegate(ctxt, _delegateDeserializer.deserialize(jp, ctxt)); } final Collection<String> result = (Collection<String>) _valueInstantiator.createUsingDefault(ctxt); return deserialize(jp, ctxt, result); } @Override public Collection<String> deserialize(JsonParser jp, DeserializationContext ctxt, Collection<String> result) throws IOException { // Ok: must point to START_ARRAY if (!jp.isExpectedStartArrayToken()) { return handleNonArray(jp, ctxt, result); } if (_valueDeserializer != null) { return deserializeUsingCustom(jp, ctxt, result, _valueDeserializer); } try { while (true) { // First the common case: String value = jp.nextTextValue(); if (value != null) { result.add(value); continue; } JsonToken t = jp.getCurrentToken(); if (t == JsonToken.END_ARRAY) { break; } if (t != JsonToken.VALUE_NULL) { value = _parseString(jp, ctxt); } result.add(value); } } catch (Exception e) { throw JsonMappingException.wrapWithPath(e, result, result.size()); } return result; } private Collection<String> deserializeUsingCustom(JsonParser jp, DeserializationContext ctxt, Collection<String> result, final JsonDeserializer<String> deser) throws IOException { while (true) { /* 30-Dec-2014, tatu: This may look odd, but let's actually call method * that suggest we are expecting a String; this helps with

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> threads. */ protected transient Map<Object,Object> _nonShared; /* /********************************************************** /* Construction, factory methods /********************************************************** */ protected Impl(Map<Object,Object> shared) { _shared = shared; _nonShared = null; } protected Impl(Map<Object,Object> shared, Map<Object,Object> nonShared) { _shared = shared; _nonShared = nonShared; } public static ContextAttributes getEmpty() { return EMPTY; } /* /********************************************************** /* Per-reader/writer mutant factories /********************************************************** */ @Override public ContextAttributes withSharedAttribute(Object key, Object value) { Map<Object,Object> m; // need to cover one special case, since EMPTY uses Immutable map: if (this == EMPTY) { m = new HashMap<Object,Object>(8); } else { m = _copy(_shared); } m.put(key, value); return new Impl(m); } @Override public ContextAttributes withSharedAttributes(Map<Object, Object> shared) { return new Impl(shared); } @Override public ContextAttributes withoutSharedAttribute(Object key) { // first couple of trivial optimizations if (_shared.isEmpty()) { return this; } if (_shared.containsKey(key)) { if (_shared.size() == 1) { return EMPTY; } } else { // if we didn't have it anyway, return as-is return this; } // otherwise make copy, modify Map<Object,Object> m = _copy(_shared); m.remove(key); return new Impl(m); } /* /********************************************************** /* Per-call access /********************************************************** */ @Override public Object getAttribute(Object key) { if (_nonShared != null) { Object ob = _nonShared.get(key); if (ob != null) { if (ob == NULL_SURROGATE) { return null; } return ob; } } return _shared.get(key); } @Override public ContextAttributes withPerCallAttribute(Object key, Object value)

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> { // First: null value may need masking if (value == null) { // need to mask nulls to ensure default values won't be showing if (_shared.containsKey(key)) { value = NULL_SURROGATE; } else { // except if non-mutable shared list has no entry, we don't care return this; } } // a special case: create non-shared instance if need be if (_nonShared == null) { return nonSharedInstance(key, value); } _nonShared.put(key, value); return this; } /* /********************************************************** /* Internal methods /********************************************************** */ /** * Overridable method that creates initial non-shared instance, * with the first explicit set value. */ protected ContextAttributes nonSharedInstance(Object key, Object value) { Map<Object,Object> m = new HashMap<Object,Object>(); if (value == null) { value = NULL_SURROGATE; } m.put(key, value); return new Impl(_shared, m); } private Map<Object,Object> _copy(Map<Object,Object> src) { return new HashMap<Object,Object>(src); } } }

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> return new UnwrappingBeanSerializer(this, objectIdWriter); } @Override protected BeanSerializerBase withFilterId(Object filterId) { return new UnwrappingBeanSerializer(this, _objectIdWriter, filterId); } @Override protected BeanSerializerBase withIgnorals(String[] toIgnore) { return new UnwrappingBeanSerializer(this, toIgnore); } /** * JSON Array output can not be done if unwrapping operation is * requested; so implementation will simply return 'this'. */ @Override protected BeanSerializerBase asArraySerializer() { return this; } /* /********************************************************** /* JsonSerializer implementation that differs between impls /********************************************************** */ /** * Main serialization method that will delegate actual output to * configured * {@link BeanPropertyWriter} instances. */ @Override public final void serialize(Object bean, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonGenerationException { if (_objectIdWriter != null) { _serializeWithObjectId(bean, jgen, provider, false); return; } if (_propertyFilterId != null) { serializeFieldsFiltered(bean, jgen, provider); } else { serializeFields(bean, jgen, provider); } } @Override public void serializeWithType(Object bean, JsonGenerator jgen, SerializerProvider provider, TypeSerializer typeSer) throws IOException, JsonGenerationException { if (provider.isEnabled(SerializationFeature.FAIL_ON_UNWRAPPED_TYPE_IDENTIFIERS)) { throw new JsonMappingException("Unwrapped property requires use of type information: can not serialize without disabling `SerializationFeature.FAIL_ON_UNWRAPPED_TYPE_IDENTIFIERS`"); } if (_objectIdWriter != null) { _serializeWithObjectId(bean, jgen, provider, typeSer); return; } if (_propertyFilterId != null) { serializeFieldsFiltered(bean, jgen, provider); } else { serializeFields(bean, jgen, provider); } } /* /********************************************************** /* Standard methods /********************************************************** */ @Override public String toString() { return "UnwrappingBeanSerializer for "+handledType().getName(); } }

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> void testBeanUpdate() throws Exception { Bean bean = new Bean(); assertEquals("b", bean.b); assertEquals(3, bean.c.length); assertNull(bean.child); Object ob = MAPPER.readerForUpdating(bean).readValue("{ \"b\":\"x\", \"c\":[4,5], \"child\":{ \"a\":\"y\"} }"); assertSame(ob, bean); assertEquals("a", bean.a); assertEquals("x", bean.b); assertArrayEquals(new int[] { 4, 5 }, bean.c); Bean child = bean.child; assertNotNull(child); assertEquals("y", child.a); assertEquals("b", child.b); assertArrayEquals(new int[] { 1, 2, 3 }, child.c); assertNull(child.child); } public void testListUpdate() throws Exception { List<String> strs = new ArrayList<String>(); strs.add("a"); // for lists, we will be appending entries Object ob = MAPPER.readerForUpdating(strs).readValue("[ \"b\", \"c\", \"d\" ]"); assertSame(strs, ob); assertEquals(4, strs.size()); assertEquals("a", strs.get(0)); assertEquals("b", strs.get(1)); assertEquals("c", strs.get(2)); assertEquals("d", strs.get(3)); } public void testMapUpdate() throws Exception { Map<String,String> strs = new HashMap<String,String>(); strs.put("a", "a"); strs.put("b", "b"); // for maps, we will be adding and/or overwriting entries Object ob = MAPPER.readerForUpdating(strs).readValue("{ \"c\" : \"c\", \"a\" : \"z\" }"); assertSame(strs, ob); assertEquals(3, strs.size()); assertEquals("z", strs.get("a")); assertEquals("b", strs.get("b")); assertEquals("c", strs.get("c")); } // Test for [JACKSON-717] -- ensure 'readValues' also does update @SuppressWarnings("resource") public void testUpdateSequence()

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>package com.fasterxml.jackson.databind.ser.std; import java.lang.reflect.Type; import java.io.IOException; import com.fasterxml.jackson.core.*; import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.annotation.JacksonStdImpl; import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitorWrapper; import com.fasterxml.jackson.databind.jsontype.TypeSerializer; /** * This is a simple dummy serializer that will just output literal * JSON null value whenever serialization is requested. * Used as the default "null serializer" (which is used for serializing * null object references unless overridden), as well as for some * more exotic types (java.lang.Void). */ @JacksonStdImpl @SuppressWarnings("serial") public class NullSerializer extends StdSerializer<Object> { public final static NullSerializer instance = new NullSerializer(); private NullSerializer() { super(Object.class); } @Override public void serialize(Object value, JsonGenerator gen, SerializerProvider provider) throws IOException { gen.writeNull(); } /** * Although this method should rarely get called, for convenience we should override * it, and handle it same way as "natural" types: by serializing exactly as is, * without type decorations. The most common possible use case is that of delegation * by JSON filter; caller can not know what kind of serializer it gets handed. */ @Override public void serializeWithType(Object value, JsonGenerator gen, SerializerProvider serializers, TypeSerializer typeSer) throws IOException { gen.writeNull(); } @Override public JsonNode getSchema(SerializerProvider provider, Type typeHint) throws JsonMappingException { return createSchemaNode("null"); } @Override public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) throws JsonMappingException { visitor.expectNullFormat(typeHint); } }

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> final int len = props.length; BeanPropertyWriter[] result = new BeanPropertyWriter[len]; for (int i = 0; i < len; ++i) { BeanPropertyWriter bpw = props[i]; if (bpw != null) { result[i] = bpw.rename(transformer); } } return result; } /* /********************************************************** /* Post-constriction processing: resolvable, contextual /********************************************************** */ /** * We need to implement {@link ResolvableSerializer} to be able to * properly handle cyclic type references. */ @Override public void resolve(SerializerProvider provider) throws JsonMappingException { int filteredCount = (_filteredProps == null) ? 0 : _filteredProps.length; for (int i = 0, len = _props.length; i < len; ++i) { BeanPropertyWriter prop = _props[i]; // let's start with null serializer resolution actually if (!prop.willSuppressNulls() && !prop.hasNullSerializer()) { JsonSerializer<Object> nullSer = provider.findNullValueSerializer(prop); if (nullSer != null) { prop.assignNullSerializer(nullSer); // also: remember to replace filtered property too? (see [JACKSON-364]) if (i < filteredCount) { BeanPropertyWriter w2 = _filteredProps[i]; if (w2 != null) { w2.assignNullSerializer(nullSer); } } } } if (prop.hasSerializer()) { continue; } // [Issue#124]: allow use of converters JsonSerializer<Object> ser = findConvertingSerializer(provider, prop); if (ser == null) { // Was the serialization type hard-coded? If so, use it JavaType type = prop.getSerializationType(); // It not, we can use declared return type if and only if declared type is final: // if not, we don't really know the actual type until we get the instance. if (type == null) { type = provider.constructType(prop.getGenericPropertyType()); if (!type.isFinal()) { if (type.isContainerType() || type.containedType

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>Count() > 0) { prop.setNonTrivialBaseType(type); } continue; } } ser = provider.findValueSerializer(type, prop); /* 04-Feb-2010, tatu: We may have stashed type serializer for content types * too, earlier; if so, it's time to connect the dots here: */ if (type.isContainerType()) { TypeSerializer typeSer = type.getContentType().getTypeHandler(); if (typeSer != null) { // for now, can do this only for standard containers... if (ser instanceof ContainerSerializer<?>) { // ugly casts... but necessary @SuppressWarnings("unchecked") JsonSerializer<Object> ser2 = (JsonSerializer<Object>)((ContainerSerializer<?>) ser).withValueTypeSerializer(typeSer); ser = ser2; } } } } prop.assignSerializer(ser); // and maybe replace filtered property too? (see [JACKSON-364]) if (i < filteredCount) { BeanPropertyWriter w2 = _filteredProps[i]; if (w2 != null) { w2.assignSerializer(ser); } } } // also, any-getter may need to be resolved if (_anyGetterWriter != null) { // 23-Feb-2015, tatu: Misleading, as this actually triggers call to contextualization... _anyGetterWriter.resolve(provider); } } /** * Helper method that can be used to see if specified property is annotated * to indicate use of a converter for property value (in case of container types, * it is container type itself, not key or content type). * * @since 2.2 */ protected JsonSerializer<Object> findConvertingSerializer(SerializerProvider provider, BeanPropertyWriter prop) throws JsonMappingException { final AnnotationIntrospector intr = provider.getAnnotationIntrospector(); if (intr != null) { AnnotatedMember m = prop.getMember(); if (m != null) { Object convDef = intr.findSerializationConverter(m); if (convDef != null) { Converter<Object,Object> conv = provider.converterInstance(prop.getMember

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>(), convDef); JavaType delegateType = conv.getOutputType(provider.getTypeFactory()); JsonSerializer<?> ser = provider.findValueSerializer(delegateType, prop); return new StdDelegatingSerializer(conv, delegateType, ser); } } } return null; } @SuppressWarnings("incomplete-switch") @Override public JsonSerializer<?> createContextual(SerializerProvider provider, BeanProperty property) throws JsonMappingException { final AnnotationIntrospector intr = provider.getAnnotationIntrospector(); final AnnotatedMember accessor = (property == null || intr == null) ? null : property.getMember(); final SerializationConfig config = provider.getConfig(); // Let's start with one big transmutation: Enums that are annotated // to serialize as Objects may want to revert JsonFormat.Shape shape = null; if (accessor != null) { JsonFormat.Value format = intr.findFormat((Annotated) accessor); if (format != null) { shape = format.getShape(); // or, alternatively, asked to revert "back to" other representations... if (shape != _serializationShape) { if (_handledType.isEnum()) { switch (shape) { case STRING: case NUMBER: case NUMBER_INT: // 12-Oct-2014, tatu: May need to introspect full annotations... but // for now, just do class ones BeanDescription desc = config.introspectClassAnnotations(_handledType); JsonSerializer<?> ser = EnumSerializer.construct(_handledType, provider.getConfig(), desc, format); return provider.handlePrimaryContextualization(ser, property); } } } } } ObjectIdWriter oiw = _objectIdWriter; String[] ignorals = null; Object newFilterId = null; // Then we may have an override for Object Id if (accessor != null) { ignorals = intr.findPropertiesToIgnore(accessor); ObjectIdInfo objectIdInfo = intr.findObjectIdInfo(accessor); if (objectIdInfo == null) { // no ObjectId override, but maybe ObjectIdRef? if (oiw != null) { objectIdInfo = intr.findObjectReferenceInfo(accessor, new ObjectIdInfo(NAME_FOR_OBJECT_REF, null, null

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>, provider); } } catch (Exception e) { String name = (i == props.length) ? "[anySetter]" : props[i].getName(); wrapAndThrow(provider, e, bean, name); } catch (StackOverflowError e) { /* 04-Sep-2009, tatu: Dealing with this is tricky, since we do not * have many stack frames to spare... just one or two; can't * make many calls. */ JsonMappingException mapE = new JsonMappingException("Infinite recursion (StackOverflowError)", e); String name = (i == props.length) ? "[anySetter]" : props[i].getName(); mapE.prependPath(new JsonMappingException.Reference(bean, name)); throw mapE; } } /** * Alternative serialization method that gets called when there is a * {@link PropertyFilter} that needs to be called to determine * which properties are to be serialized (and possibly how) */ protected void serializeFieldsFiltered(Object bean, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonGenerationException { /* note: almost verbatim copy of "serializeFields"; copied (instead of merged) * so that old method need not add check for existence of filter. */ final BeanPropertyWriter[] props; if (_filteredProps != null && provider.getActiveView() != null) { props = _filteredProps; } else { props = _props; } final PropertyFilter filter = findPropertyFilter(provider, _propertyFilterId, bean); // better also allow missing filter actually.. if (filter == null) { serializeFields(bean, jgen, provider); return; } int i = 0; try { for (final int len = props.length; i < len; ++i) { BeanPropertyWriter prop = props[i]; if (prop != null) { // can have nulls in filtered list filter.serializeAsField(bean, jgen, provider, prop); } } if (_anyGetterWriter != null) { _anyGetterWriter.getAndFilter(bean, jgen, provider, filter); } } catch (Exception e) { String name = (i

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> == props.length) ? "[anySetter]" : props[i].getName(); wrapAndThrow(provider, e, bean, name); } catch (StackOverflowError e) { JsonMappingException mapE = new JsonMappingException("Infinite recursion (StackOverflowError)", e); String name = (i == props.length) ? "[anySetter]" : props[i].getName(); mapE.prependPath(new JsonMappingException.Reference(bean, name)); throw mapE; } } @Deprecated @Override public JsonNode getSchema(SerializerProvider provider, Type typeHint) throws JsonMappingException { ObjectNode o = createSchemaNode("object", true); // [JACKSON-813]: Add optional JSON Schema id attribute, if found // NOTE: not optimal, does NOT go through AnnotationIntrospector etc: JsonSerializableSchema ann = _handledType.getAnnotation(JsonSerializableSchema.class); if (ann != null) { String id = ann.id(); if (id != null && id.length() > 0) { o.put("id", id); } } //todo: should the classname go in the title? //o.put("title", _className); ObjectNode propertiesNode = o.objectNode(); final PropertyFilter filter; if (_propertyFilterId != null) { filter = findPropertyFilter(provider, _propertyFilterId, null); } else { filter = null; } for (int i = 0; i < _props.length; i++) { BeanPropertyWriter prop = _props[i]; if (filter == null) { prop.depositSchemaProperty(propertiesNode, provider); } else { filter.depositSchemaProperty(prop, propertiesNode, provider); } } o.put("properties", propertiesNode); return o; } @Override public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) throws JsonMappingException { //deposit your output format if (visitor == null) { return; } JsonObjectFormatVisitor objectVisitor = visitor.expectObjectFormat(typeHint); if (objectVisitor == null) { return; } if (_propertyFilterId != null) { PropertyFilter filter =

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> = 0, len = args.length; i < len; i += 2) { map.put(args[i], args[i+1]); } return m.writeValueAsString(map); } /* /********************************************************** /* Helper methods, deserialization /********************************************************** */ protected <T> T readAndMapFromString(String input, Class<T> cls) throws IOException { return readAndMapFromString(SHARED_MAPPER, input, cls); } protected <T> T readAndMapFromString(ObjectMapper m, String input, Class<T> cls) throws IOException { return (T) m.readValue("\""+input+"\"", cls); } /* /********************************************************** /* Helper methods, other /********************************************************** */ protected TimeZone getUTCTimeZone() { return TimeZone.getTimeZone("GMT"); } protected byte[] utf8Bytes(String str) { try { return str.getBytes("UTF-8"); } catch (IOException e) { throw new IllegalArgumentException(e); } } protected static String aposToQuotes(String json) { return json.replace("'", "\""); } }

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>package com.fasterxml.jackson.databind.ser.impl; import java.io.IOException; import java.lang.reflect.Type; import com.fasterxml.jackson.core.*; import com.fasterxml.jackson.databind.JavaType; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitorWrapper; import com.fasterxml.jackson.databind.ser.std.StdSerializer; /** * Special bogus "serializer" that will throw * {@link JsonGenerationException} if its {@link #serialize} * gets invoked. Most commonly registered as handler for unknown types, * as well as for catching unintended usage (like trying to use null * as Map/Object key). */ @SuppressWarnings("serial") public class FailingSerializer extends StdSerializer<Object> { protected final String _msg; public FailingSerializer(String msg) { super(Object.class); _msg = msg; } @Override public void serialize(Object value, JsonGenerator jgen, SerializerProvider provider) throws IOException { throw new JsonGenerationException(_msg); } @Override public JsonNode getSchema(SerializerProvider provider, Type typeHint) throws JsonMappingException { return null; } @Override public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) { ; } }

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> associated schema. * Equivalent to: *<code> * getMetadata().isRequired() *</code> * * @since 2.2 */ public boolean isRequired(); /** * Method for finding annotation associated with this property; * meaning annotation associated with one of entities used to * access property. */ public <A extends Annotation> A getAnnotation(Class<A> acls); /** * Method for finding annotation associated with context of * this property; usually class in which member is declared * (or its subtype if processing subtype). */ public <A extends Annotation> A getContextAnnotation(Class<A> acls); /** * Method for accessing primary physical entity that represents the property; * annotated field, method or constructor property. */ public AnnotatedMember getMember(); /** * Method that can be called to visit the type structure that this * property is part of. * Note that not all implementations support traversal with this * method; those that do not should throw * {@link UnsupportedOperationException}. * * @param objectVisitor Visitor to used as the callback handler * * @since 2.2 */ public void depositSchemaProperty(JsonObjectFormatVisitor objectVisitor) throws JsonMappingException; /* /********************************************************** /* Helper classes /********************************************************** */ /** * Simple stand-alone implementation, useful as a placeholder * or base class for more complex implementations. */ public static class Std implements BeanProperty { protected final PropertyName _name; protected final JavaType _type; protected final PropertyName _wrapperName; protected final PropertyMetadata _metadata; /** * Physical entity (field, method or constructor argument) that * is used to access value of property (or in case of constructor * property, just placeholder) */ protected final AnnotatedMember _member; /** * Annotations defined in the context class (if any); may be null * if no annotations were found */ protected final Annotations _contextAnnotations; public Std(PropertyName name, JavaType type, PropertyName wrapperName, Annotations contextAnnotations, AnnotatedMember member, PropertyMetadata metadata) { _name = name; _type = type; _wrapperName = wrapperName; _metadata = metadata; _

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>package com.fasterxml.jackson.databind.module; import java.util.*; import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.deser.Deserializers; import com.fasterxml.jackson.databind.jsontype.TypeDeserializer; import com.fasterxml.jackson.databind.type.*; /** * Simple implementation {@link Deserializers} which allows registration of * deserializers based on raw (type erased class). * It can work well for basic bean and scalar type deserializers, but is not * a good fit for handling generic types (like {@link Map}s and {@link Collection}s * or array types). *<p> * Unlike {@link SimpleSerializers}, this class does not currently support generic mappings; * all mappings must be to exact declared deserialization type. */ public class SimpleDeserializers implements Deserializers, java.io.Serializable { private static final long serialVersionUID = -3006673354353448880L; protected HashMap<ClassKey,JsonDeserializer<?>> _classMappings = null; /** * Flag to help find "generic" enum deserializer, if one has been registered. * * @since 2.3 */ protected boolean _hasEnumDeserializer = false; /* /********************************************************** /* Life-cycle, construction and configuring /********************************************************** */ public SimpleDeserializers() { } /** * @since 2.1 */ public SimpleDeserializers(Map<Class<?>,JsonDeserializer<?>> desers) { addDeserializers(desers); } public <T> void addDeserializer(Class<T> forClass, JsonDeserializer<? extends T> deser) { ClassKey key = new ClassKey(forClass); if (_classMappings == null) { _classMappings = new HashMap<ClassKey,JsonDeserializer<?>>(); } _classMappings.put(key, deser); // [Issue#227]: generic Enum deserializer? if (forClass == Enum.class) { _hasEnumDeserializer = true; } } /** * @since 2.1 */ @SuppressWarnings("unchecked") public void addDeserializers(Map<Class<?>,JsonDeserializer<?>> desers)

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> { for (Map.Entry<Class<?>,JsonDeserializer<?>> entry : desers.entrySet()) { Class<?> cls = entry.getKey(); // what a mess... nominal generics safety... JsonDeserializer<Object> deser = (JsonDeserializer<Object>) entry.getValue(); addDeserializer((Class<Object>) cls, deser); } } /* /********************************************************** /* Serializers implementation /********************************************************** */ @Override public JsonDeserializer<?> findArrayDeserializer(ArrayType type, DeserializationConfig config, BeanDescription beanDesc, TypeDeserializer elementTypeDeserializer, JsonDeserializer<?> elementDeserializer) throws JsonMappingException { return (_classMappings == null) ? null : _classMappings.get(new ClassKey(type.getRawClass())); } @Override public JsonDeserializer<?> findBeanDeserializer(JavaType type, DeserializationConfig config, BeanDescription beanDesc) throws JsonMappingException { return (_classMappings == null) ? null : _classMappings.get(new ClassKey(type.getRawClass())); } @Override public JsonDeserializer<?> findCollectionDeserializer(CollectionType type, DeserializationConfig config, BeanDescription beanDesc, TypeDeserializer elementTypeDeserializer, JsonDeserializer<?> elementDeserializer) throws JsonMappingException { return (_classMappings == null) ? null : _classMappings.get(new ClassKey(type.getRawClass())); } @Override public JsonDeserializer<?> findCollectionLikeDeserializer(CollectionLikeType type, DeserializationConfig config, BeanDescription beanDesc, TypeDeserializer elementTypeDeserializer, JsonDeserializer<?> elementDeserializer) throws JsonMappingException { return (_classMappings == null) ? null : _classMappings.get(new ClassKey(type.getRawClass())); } @Override public JsonDeserializer<?> findEnumDeserializer(Class<?> type, DeserializationConfig config, BeanDescription beanDesc) throws JsonMappingException { if (_classMappings == null) { return null; } JsonDeserializer<?> deser = _classMappings.get(new ClassKey(type)); if (deser == null) { if (_hasEnumDeserializer && type.isEnum()) { deser = _classMappings.get(new ClassKey(Enum.class)); } } return deser; } @Override public JsonDeserializer<?> findMap

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>Deserializer(MapType type, DeserializationConfig config, BeanDescription beanDesc, KeyDeserializer keyDeserializer, TypeDeserializer elementTypeDeserializer, JsonDeserializer<?> elementDeserializer) throws JsonMappingException { return (_classMappings == null) ? null : _classMappings.get(new ClassKey(type.getRawClass())); } @Override public JsonDeserializer<?> findMapLikeDeserializer(MapLikeType type, DeserializationConfig config, BeanDescription beanDesc, KeyDeserializer keyDeserializer, TypeDeserializer elementTypeDeserializer, JsonDeserializer<?> elementDeserializer) throws JsonMappingException { return (_classMappings == null) ? null : _classMappings.get(new ClassKey(type.getRawClass())); } @Override public JsonDeserializer<?> findTreeNodeDeserializer(Class<? extends JsonNode> nodeType, DeserializationConfig config, BeanDescription beanDesc) throws JsonMappingException { return (_classMappings == null) ? null : _classMappings.get(new ClassKey(nodeType)); } }

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> return (Collection<Object>) _valueInstantiator.createUsingDelegate(ctxt, _delegateDeserializer.deserialize(jp, ctxt)); } if (jp.getCurrentToken() == JsonToken.VALUE_STRING) { String str = jp.getText(); if (str.length() == 0) { return (Collection<Object>) _valueInstantiator.createFromString(ctxt, str); } } return deserialize(jp, ctxt, null); } @Override public Collection<Object> deserialize(JsonParser jp, DeserializationContext ctxt, Collection<Object> result0) throws IOException { // Ok: must point to START_ARRAY (or equivalent) if (!jp.isExpectedStartArrayToken()) { return handleNonArray(jp, ctxt, new ArrayBlockingQueue<Object>(1)); } ArrayList<Object> tmp = new ArrayList<Object>(); JsonDeserializer<Object> valueDes = _valueDeserializer; JsonToken t; final TypeDeserializer typeDeser = _valueTypeDeserializer; try { while ((t = jp.nextToken()) != JsonToken.END_ARRAY) { Object value; if (t == JsonToken.VALUE_NULL) { value = valueDes.getNullValue(); } else if (typeDeser == null) { value = valueDes.deserialize(jp, ctxt); } else { value = valueDes.deserializeWithType(jp, ctxt, typeDeser); } tmp.add(value); } } catch (Exception e) { throw JsonMappingException.wrapWithPath(e, tmp, tmp.size()); } if (result0 != null) { result0.addAll(tmp); return result0; } return new ArrayBlockingQueue<Object>(tmp.size(), false, tmp); } @Override public Object deserializeWithType(JsonParser jp, DeserializationContext ctxt, TypeDeserializer typeDeserializer) throws IOException { // In future could check current token... for now this should be enough: return typeDeserializer.deserializeTypedFromArray(jp, ctxt); } }

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> no view has been set. */ public abstract Class<?> getActiveView(); /* /********************************************************** /* Generic attributes (2.3+) /********************************************************** */ /** * Method for accessing attributes available in this context. * Per-call attributes have highest precedence; attributes set * via {@link ObjectReader} or {@link ObjectWriter} have lower * precedence. * * @param key Key of the attribute to get * @return Value of the attribute, if any; null otherwise * * @since 2.3 */ public abstract Object getAttribute(Object key); /** * Method for setting per-call value of given attribute. * This will override any previously defined value for the * attribute within this context. * * @param key Key of the attribute to set * @param value Value to set attribute to * * @return This context object, to allow chaining * * @since 2.3 */ public abstract DatabindContext setAttribute(Object key, Object value); /* /********************************************************** /* Type instantiation/resolution /********************************************************** */ /** * Convenience method for constructing {@link JavaType} for given JDK * type (usually {@link java.lang.Class}) */ public JavaType constructType(Type type) { return getTypeFactory().constructType(type); } /** * Convenience method for constructing subtypes, retaining generic * type parameter (if any) */ public JavaType constructSpecializedType(JavaType baseType, Class<?> subclass) { // simple optimization to avoid costly introspection if type-erased type does NOT differ if (baseType.getRawClass() == subclass) { return baseType; } return getConfig().constructSpecializedType(baseType, subclass); } public abstract TypeFactory getTypeFactory(); /* /********************************************************** /* Helper object construction /********************************************************** */ public ObjectIdGenerator<?> objectIdGeneratorInstance(Annotated annotated, ObjectIdInfo objectIdInfo) throws JsonMappingException { Class<?> implClass = objectIdInfo.getGeneratorType(); final MapperConfig<?> config = getConfig(); HandlerInstantiator hi = config.getHandlerInstantiator(); ObjectIdGenerator<?> gen = (hi == null) ? null : hi.objectIdGeneratorInstance(config,

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> annotated, implClass); if (gen == null) { gen = (ObjectIdGenerator<?>) ClassUtil.createInstance(implClass, config.canOverrideAccessModifiers()); } return gen.forScope(objectIdInfo.getScope()); } public ObjectIdResolver objectIdResolverInstance(Annotated annotated, ObjectIdInfo objectIdInfo) { Class<? extends ObjectIdResolver> implClass = objectIdInfo.getResolverType(); final MapperConfig<?> config = getConfig(); HandlerInstantiator hi = config.getHandlerInstantiator(); ObjectIdResolver resolver = (hi == null) ? null : hi.resolverIdGeneratorInstance(config, annotated, implClass); if (resolver == null) { resolver = ClassUtil.createInstance(implClass, config.canOverrideAccessModifiers()); } return resolver; } /** * Helper method to use to construct a {@link Converter}, given a definition * that may be either actual converter instance, or Class for instantiating one. * * @since 2.2 */ @SuppressWarnings("unchecked") public Converter<Object,Object> converterInstance(Annotated annotated, Object converterDef) throws JsonMappingException { if (converterDef == null) { return null; } if (converterDef instanceof Converter<?,?>) { return (Converter<Object,Object>) converterDef; } if (!(converterDef instanceof Class)) { throw new IllegalStateException("AnnotationIntrospector returned Converter definition of type " +converterDef.getClass().getName()+"; expected type Converter or Class<Converter> instead"); } Class<?> converterClass = (Class<?>)converterDef; // there are some known "no class" markers to consider too: if (converterClass == Converter.None.class || ClassUtil.isBogusClass(converterClass)) { return null; } if (!Converter.class.isAssignableFrom(converterClass)) { throw new IllegalStateException("AnnotationIntrospector returned Class " +converterClass.getName()+"; expected Class<Converter>"); } final MapperConfig<?> config = getConfig(); HandlerInstantiator hi = config.getHandlerInstantiator(); Converter<?,?> conv = (hi == null) ? null : hi.converterInstance(config, annotated, converterClass); if (conv == null) { conv = (Converter<?,?>) ClassUtil.create

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> generally that * is not what we want, since lack of type information would imply real * String type. */ /** * Default implementation will write type prefix, call regular serialization * method (since assumption is that value itself does not need JSON * Array or Object start/end markers), and then write type suffix. * This should work for most cases; some sub-classes may want to * change this behavior. */ @Override public void serializeWithType(Object value, JsonGenerator gen, SerializerProvider provider, TypeSerializer typeSer) throws IOException { typeSer.writeTypePrefixForScalar(value, gen); serialize(value, gen, provider); typeSer.writeTypeSuffixForScalar(value, gen); } @Override public JsonNode getSchema(SerializerProvider provider, Type typeHint) throws JsonMappingException { return createSchemaNode("string", true); } @Override public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) throws JsonMappingException { if (visitor != null) { visitor.expectStringFormat(typeHint); } } }

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> } catch (UnresolvedForwardReference reference) { boolean usingIdentityInfo = (_objectIdInfo != null) || (_valueDeserializer.getObjectIdReader() != null); if (!usingIdentityInfo) { throw JsonMappingException.from(jp, "Unresolved forward reference but no identity info.", reference); } reference.getRoid().appendReferring(new PropertyReferring(this, reference, _type.getRawClass(), instance)); return null; } } @Override public void set(Object instance, Object value) throws IOException { _forward.set(instance, value); } @Override public Object setAndReturn(Object instance, Object value) throws IOException { return _forward.setAndReturn(instance, value); } public final static class PropertyReferring extends Referring { private final ObjectIdReferenceProperty _parent; public final Object _pojo; public PropertyReferring(ObjectIdReferenceProperty parent, UnresolvedForwardReference ref, Class<?> type, Object ob) { super(ref, type); _parent = parent; _pojo = ob; } @Override public void handleResolvedForwardReference(Object id, Object value) throws IOException { if (!hasId(id)) { throw new IllegalArgumentException("Trying to resolve a forward reference with id [" + id + "] that wasn't previously seen as unresolved."); } _parent.set(_pojo, value); } } }

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> super(Object[].class, null); _elementType = elemType; _staticTyping = staticTyping; _valueTypeSerializer = vts; _dynamicSerializers = PropertySerializerMap.emptyForProperties(); _elementSerializer = elementSerializer; } public ObjectArraySerializer(ObjectArraySerializer src, TypeSerializer vts) { super(src); _elementType = src._elementType; _valueTypeSerializer = vts; _staticTyping = src._staticTyping; _dynamicSerializers = src._dynamicSerializers; _elementSerializer = src._elementSerializer; } @SuppressWarnings("unchecked") public ObjectArraySerializer(ObjectArraySerializer src, BeanProperty property, TypeSerializer vts, JsonSerializer<?> elementSerializer) { super(src, property); _elementType = src._elementType; _valueTypeSerializer = vts; _staticTyping = src._staticTyping; _dynamicSerializers = src._dynamicSerializers; _elementSerializer = (JsonSerializer<Object>) elementSerializer; } @Override public ContainerSerializer<?> _withValueTypeSerializer(TypeSerializer vts) { return new ObjectArraySerializer(_elementType, _staticTyping, vts, _elementSerializer); } public ObjectArraySerializer withResolved(BeanProperty prop, TypeSerializer vts, JsonSerializer<?> ser) { if (_property == prop && ser == _elementSerializer && _valueTypeSerializer == vts) { return this; } return new ObjectArraySerializer(this, prop, vts, ser); } /* /********************************************************** /* Post-processing /********************************************************** */ @Override public JsonSerializer<?> createContextual(SerializerProvider provider, BeanProperty property) throws JsonMappingException { TypeSerializer vts = _valueTypeSerializer; if (vts != null) { vts = vts.forProperty(property); } /* 29-Sep-2012, tatu: Actually, we need to do much more contextual * checking here since we finally know for sure the property, * and it may have overrides */ JsonSerializer<?> ser = null; // First: if we have a property, may have property-annotation overrides if (property != null) { AnnotatedMember m = property.getMember(); if (m != null

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> if (_elementSerializer != null) { serializeContentsUsing(value, jgen, provider, _elementSerializer); return; } if (_valueTypeSerializer != null) { serializeTypedContents(value, jgen, provider); return; } int i = 0; Object elem = null; try { PropertySerializerMap serializers = _dynamicSerializers; for (; i < len; ++i) { elem = value[i]; if (elem == null) { provider.defaultSerializeNull(jgen); continue; } Class<?> cc = elem.getClass(); JsonSerializer<Object> serializer = serializers.serializerFor(cc); if (serializer == null) { // To fix [JACKSON-508] if (_elementType.hasGenericTypes()) { serializer = _findAndAddDynamic(serializers, provider.constructSpecializedType(_elementType, cc), provider); } else { serializer = _findAndAddDynamic(serializers, cc, provider); } } serializer.serialize(elem, jgen, provider); } } catch (IOException ioe) { throw ioe; } catch (Exception e) { // [JACKSON-55] Need to add reference information /* 05-Mar-2009, tatu: But one nasty edge is when we get * StackOverflow: usually due to infinite loop. But that gets * hidden within an InvocationTargetException... */ Throwable t = e; while (t instanceof InvocationTargetException && t.getCause() != null) { t = t.getCause(); } if (t instanceof Error) { throw (Error) t; } throw JsonMappingException.wrapWithPath(t, elem, i); } } public void serializeContentsUsing(Object[] value, JsonGenerator jgen, SerializerProvider provider, JsonSerializer<Object> ser) throws IOException { final int len = value.length; final TypeSerializer typeSer = _valueTypeSerializer; int i = 0; Object elem = null; try { for (; i < len; ++i) { elem = value[i]; if (elem == null) { provider.defaultSerializeNull(jgen); continue; } if (type

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>Ser == null) { ser.serialize(elem, jgen, provider); } else { ser.serializeWithType(elem, jgen, provider, typeSer); } } } catch (IOException ioe) { throw ioe; } catch (Exception e) { Throwable t = e; while (t instanceof InvocationTargetException && t.getCause() != null) { t = t.getCause(); } if (t instanceof Error) { throw (Error) t; } throw JsonMappingException.wrapWithPath(t, elem, i); } } public void serializeTypedContents(Object[] value, JsonGenerator jgen, SerializerProvider provider) throws IOException { final int len = value.length; final TypeSerializer typeSer = _valueTypeSerializer; int i = 0; Object elem = null; try { PropertySerializerMap serializers = _dynamicSerializers; for (; i < len; ++i) { elem = value[i]; if (elem == null) { provider.defaultSerializeNull(jgen); continue; } Class<?> cc = elem.getClass(); JsonSerializer<Object> serializer = serializers.serializerFor(cc); if (serializer == null) { serializer = _findAndAddDynamic(serializers, cc, provider); } serializer.serializeWithType(elem, jgen, provider, typeSer); } } catch (IOException ioe) { throw ioe; } catch (Exception e) { Throwable t = e; while (t instanceof InvocationTargetException && t.getCause() != null) { t = t.getCause(); } if (t instanceof Error) { throw (Error) t; } throw JsonMappingException.wrapWithPath(t, elem, i); } } @SuppressWarnings("deprecation") @Override public JsonNode getSchema(SerializerProvider provider, Type typeHint) throws JsonMappingException { ObjectNode o = createSchemaNode("array", true); if (typeHint != null) { JavaType javaType = provider.constructType(typeHint); if (javaType.isArrayType()) { Class<?> componentType = ((ArrayType) javaType).getContentType().getRawClass(); // 15-Oct-2010

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>, tatu: We can't serialize plain Object.class; but what should it produce here? Untyped? if (componentType == Object.class) { o.put("items", com.fasterxml.jackson.databind.jsonschema.JsonSchema.getDefaultSchemaNode()); } else { JsonSerializer<Object> ser = provider.findValueSerializer(componentType, _property); JsonNode schemaNode = (ser instanceof SchemaAware) ? ((SchemaAware) ser).getSchema(provider, null) : com.fasterxml.jackson.databind.jsonschema.JsonSchema.getDefaultSchemaNode(); o.put("items", schemaNode); } } } return o; } @Override public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) throws JsonMappingException { JsonArrayFormatVisitor arrayVisitor = visitor.expectArrayFormat(typeHint); if (arrayVisitor != null) { TypeFactory tf = visitor.getProvider().getTypeFactory(); JavaType contentType = tf.moreSpecificType(_elementType, typeHint.getContentType()); if (contentType == null) { throw new JsonMappingException("Could not resolve type"); } JsonSerializer<?> valueSer = _elementSerializer; if (valueSer == null) { valueSer = visitor.getProvider().findValueSerializer(contentType, _property); } arrayVisitor.itemsFormat(valueSer, contentType); } } protected final JsonSerializer<Object> _findAndAddDynamic(PropertySerializerMap map, Class<?> type, SerializerProvider provider) throws JsonMappingException { PropertySerializerMap.SerializerAndMapResult result = map.findAndAddSecondarySerializer(type, provider, _property); // did we get a new map of serializers? If so, start using it if (map != result.map) { _dynamicSerializers = result.map; } return result.serializer; } protected final JsonSerializer<Object> _findAndAddDynamic(PropertySerializerMap map, JavaType type, SerializerProvider provider) throws JsonMappingException { PropertySerializerMap.SerializerAndMapResult result = map.findAndAddSecondarySerializer(type, provider, _property); // did we get a new map of serializers? If so, start using it if (map != result.map) { _dynamic

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>package com.fasterxml.jackson.databind.ser.std; import java.io.IOException; import java.lang.reflect.Type; import java.util.Map; import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.core.*; import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.annotation.JacksonStdImpl; import com.fasterxml.jackson.databind.introspect.AnnotatedMember; import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitorWrapper; import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonIntegerFormatVisitor; import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonNumberFormatVisitor; import com.fasterxml.jackson.databind.jsontype.TypeSerializer; import com.fasterxml.jackson.databind.ser.ContextualSerializer; /** * Container class for serializers used for handling standard JDK-provided types. */ @SuppressWarnings("serial") public class NumberSerializers { protected NumberSerializers() { } public static void addAll(Map<String, JsonSerializer<?>> allDeserializers) { final JsonSerializer<?> intS = new IntegerSerializer(); allDeserializers.put(Integer.class.getName(), intS); allDeserializers.put(Integer.TYPE.getName(), intS); allDeserializers.put(Long.class.getName(), LongSerializer.instance); allDeserializers.put(Long.TYPE.getName(), LongSerializer.instance); allDeserializers.put(Byte.class.getName(), IntLikeSerializer.instance); allDeserializers.put(Byte.TYPE.getName(), IntLikeSerializer.instance); allDeserializers.put(Short.class.getName(), ShortSerializer.instance); allDeserializers.put(Short.TYPE.getName(), ShortSerializer.instance); // Numbers, limited length floating point allDeserializers.put(Float.class.getName(), FloatSerializer.instance); allDeserializers.put(Float.TYPE.getName(), FloatSerializer.instance); allDeserializers.put(Double.class.getName(), DoubleSerializer.instance); allDeserializers.put(Double.TYPE.getName(), DoubleSerializer.instance); } /* /********************************************************** /* Shared base class /********************************************************** */

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> protected abstract static class Base<T> extends StdScalarSerializer<T> implements ContextualSerializer { protected final JsonParser.NumberType _numberType; protected final String _schemaType; protected final boolean _isInt; protected Base(Class<T> cls, JsonParser.NumberType numberType, String schemaType) { super(cls); _numberType = numberType; _schemaType = schemaType; _isInt = (numberType == JsonParser.NumberType.INT) || (numberType == JsonParser.NumberType.LONG) || (numberType == JsonParser.NumberType.BIG_INTEGER) ; } @Override public JsonNode getSchema(SerializerProvider provider, Type typeHint) { return createSchemaNode(_schemaType, true); } @Override public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) throws JsonMappingException { if (_isInt) { JsonIntegerFormatVisitor v2 = visitor.expectIntegerFormat(typeHint); if (v2 != null) { v2.numberType(_numberType); } } else { JsonNumberFormatVisitor v2 = visitor.expectNumberFormat(typeHint); if (v2 != null) { v2.numberType(_numberType); } } } @Override public JsonSerializer<?> createContextual(SerializerProvider prov, BeanProperty property) throws JsonMappingException { if (property != null) { AnnotatedMember m = property.getMember(); if (m != null) { JsonFormat.Value format = prov.getAnnotationIntrospector().findFormat(m); if (format != null) { switch (format.getShape()) { case STRING: return ToStringSerializer.instance; default: } } } } return this; } } /* /********************************************************** /* Concrete serializers, numerics /********************************************************** */ @JacksonStdImpl public final static class ShortSerializer extends Base<Short> { final static ShortSerializer instance = new ShortSerializer(); public ShortSerializer() { super(Short.class, JsonParser.NumberType.INT, "number"); } @Override public void serialize(Short value, JsonGenerator jgen, SerializerProvider provider) throws IOException

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> checks, just in case someone tries to force typing... if (superType == subType) { throw new IllegalArgumentException("Can not add mapping from class to itself"); } if (!superType.isAssignableFrom(subType)) { throw new IllegalArgumentException("Can not add mapping from class "+superType.getName() +" to "+subType.getName()+", as latter is not a subtype of former"); } if (!Modifier.isAbstract(superType.getModifiers())) { throw new IllegalArgumentException("Can not add mapping from class "+superType.getName() +" since it is not abstract"); } _mappings.put(new ClassKey(superType), subType); return this; } @Override public JavaType findTypeMapping(DeserializationConfig config, JavaType type) { // this is the main mapping base, so let's Class<?> src = type.getRawClass(); Class<?> dst = _mappings.get(new ClassKey(src)); if (dst == null) { return null; } return type.narrowBy(dst); } @Override public JavaType resolveAbstractType(DeserializationConfig config, JavaType type) { // never materialize anything, so: return null; } }

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>package com.fasterxml.jackson.databind.deser.std; import java.io.IOException; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.JsonToken; import com.fasterxml.jackson.databind.DeserializationContext; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.JsonMappingException; public class StackTraceElementDeserializer extends StdScalarDeserializer<StackTraceElement> { private static final long serialVersionUID = 1L; public StackTraceElementDeserializer() { super(StackTraceElement.class); } @Override public StackTraceElement deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException { JsonToken t = jp.getCurrentToken(); // Must get an Object if (t == JsonToken.START_OBJECT) { String className = "", methodName = "", fileName = ""; int lineNumber = -1; while ((t = jp.nextValue()) != JsonToken.END_OBJECT) { String propName = jp.getCurrentName(); if ("className".equals(propName)) { className = jp.getText(); } else if ("fileName".equals(propName)) { fileName = jp.getText(); } else if ("lineNumber".equals(propName)) { if (t.isNumeric()) { lineNumber = jp.getIntValue(); } else { throw JsonMappingException.from(jp, "Non-numeric token ("+t+") for property 'lineNumber'"); } } else if ("methodName".equals(propName)) { methodName = jp.getText(); } else if ("nativeMethod".equals(propName)) { // no setter, not passed via constructor: ignore } else { handleUnknownProperty(jp, ctxt, _valueClass, propName); } } return new StackTraceElement(className, methodName, fileName, lineNumber); } else if (t == JsonToken.START_ARRAY && ctxt.isEnabled(DeserializationFeature.UNWRAP_SINGLE_VALUE_ARRAYS)) { jp.nextToken(); final StackTraceElement value = deserialize(jp, ctxt); if (jp.nextToken() != JsonToken.END_ARRAY) { throw ctxt.wrongTokenException(jp, JsonToken.END_ARRAY, "Attempted to unwrap single value array for

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>** */ protected JsonDeserializer<Object> _mapDeserializer; protected JsonDeserializer<Object> _listDeserializer; protected JsonDeserializer<Object> _stringDeserializer; protected JsonDeserializer<Object> _numberDeserializer; public UntypedObjectDeserializer() { super(Object.class); } @SuppressWarnings("unchecked") public UntypedObjectDeserializer(UntypedObjectDeserializer base, JsonDeserializer<?> mapDeser, JsonDeserializer<?> listDeser, JsonDeserializer<?> stringDeser, JsonDeserializer<?> numberDeser) { super(Object.class); _mapDeserializer = (JsonDeserializer<Object>) mapDeser; _listDeserializer = (JsonDeserializer<Object>) listDeser; _stringDeserializer = (JsonDeserializer<Object>) stringDeser; _numberDeserializer = (JsonDeserializer<Object>) numberDeser; } /* /********************************************************** /* Initialization /********************************************************** */ /** * We need to implement this method to properly find things to delegate * to: it can not be done earlier since delegated deserializers almost * certainly require access to this instance (at least "List" and "Map" ones) */ @SuppressWarnings("unchecked") @Override public void resolve(DeserializationContext ctxt) throws JsonMappingException { JavaType obType = ctxt.constructType(Object.class); JavaType stringType = ctxt.constructType(String.class); TypeFactory tf = ctxt.getTypeFactory(); /* 26-Nov-2014, tatu: This is highly unusual, as in general contextualization * should always be called separately, from within "createContextual()". * But this is a very singular deserializer since it operates on `Object` * (and often for `?` type parameter), and as a result, easily and commonly * results in cycles, being value deserializer for various Maps and Collections. * Because of this, we must somehow break the cycles. This is done here by * forcing pseudo-contextualization with null property. */ // So: first find possible custom instances _mapDeserializer = _findCustomDeser(ctxt, tf.constructMapType(Map.class, stringType, obType)); _listDeserializer = _findCustomDeser(ctxt, tf.constructCollectionType(

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>List.class, obType)); _stringDeserializer = _findCustomDeser(ctxt, stringType); _numberDeserializer = _findCustomDeser(ctxt, tf.constructType(Number.class)); // and then do bogus contextualization, in case custom ones need to resolve dependencies of // their own JavaType unknown = TypeFactory.unknownType(); _mapDeserializer = (JsonDeserializer<Object>) ctxt.handleSecondaryContextualization(_mapDeserializer, null, unknown); _listDeserializer = (JsonDeserializer<Object>) ctxt.handleSecondaryContextualization(_listDeserializer, null, unknown); _stringDeserializer = (JsonDeserializer<Object>) ctxt.handleSecondaryContextualization(_stringDeserializer, null, unknown); _numberDeserializer = (JsonDeserializer<Object>) ctxt.handleSecondaryContextualization(_numberDeserializer, null, unknown); } @SuppressWarnings("unchecked") protected JsonDeserializer<Object> _findCustomDeser(DeserializationContext ctxt, JavaType type) throws JsonMappingException { // Since we are calling from `resolve`, we should NOT try to contextualize yet; // contextualization will only occur at a later point JsonDeserializer<?> deser = ctxt.findNonContextualValueDeserializer(type); if (ClassUtil.isJacksonStdImpl(deser)) { return null; } return (JsonDeserializer<Object>) deser; } /** * We only use contextualization for optimizing the case where no customization * occurred; if so, can slip in a more streamlined version. */ @Override public JsonDeserializer<?> createContextual(DeserializationContext ctxt, BeanProperty property) throws JsonMappingException { // 20-Apr-2014, tatu: If nothing custom, let's use "vanilla" instance, // simpler and can avoid some of delegation if ((_stringDeserializer == null) && (_numberDeserializer == null) && (_mapDeserializer == null) && (_listDeserializer == null) && getClass() == UntypedObjectDeserializer.class) { return Vanilla.std; } return this; } protected JsonDeserializer<?> _withResolved(JsonDeserializer<?> mapDeser, JsonDeserializer<?> listDeser, JsonDeserializer<?> stringDeser, JsonDeserializer<?> numberDeser) { return

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> ArrayList<Object> result = new ArrayList<Object>(totalSize); buffer.completeAndClearBuffer(values, ptr, result); return result; } /** * Method called to map a JSON Object into a Java value. */ protected Object mapObject(JsonParser jp, DeserializationContext ctxt) throws IOException { JsonToken t = jp.getCurrentToken(); if (t == JsonToken.START_OBJECT) { t = jp.nextToken(); } // minor optimization; let's handle 1 and 2 entry cases separately if (t == JsonToken.END_OBJECT) { // and empty one too // empty map might work; but caller may want to modify... so better just give small modifiable return new LinkedHashMap<String,Object>(2); } String field1 = jp.getCurrentName(); jp.nextToken(); Object value1 = deserialize(jp, ctxt); if (jp.nextToken() == JsonToken.END_OBJECT) { // single entry; but we want modifiable LinkedHashMap<String, Object> result = new LinkedHashMap<String, Object>(2); result.put(field1, value1); return result; } String field2 = jp.getCurrentName(); jp.nextToken(); Object value2 = deserialize(jp, ctxt); if (jp.nextToken() == JsonToken.END_OBJECT) { LinkedHashMap<String, Object> result = new LinkedHashMap<String, Object>(4); result.put(field1, value1); result.put(field2, value2); return result; } // And then the general case; default map size is 16 LinkedHashMap<String, Object> result = new LinkedHashMap<String, Object>(); result.put(field1, value1); result.put(field2, value2); do { String fieldName = jp.getCurrentName(); jp.nextToken(); result.put(fieldName, deserialize(jp, ctxt)); } while (jp.nextToken() != JsonToken.END_OBJECT); return result; } /** * Method called to map a JSON Array into a Java Object array (Object[]). */ protected Object[] mapArrayToArray(JsonParser jp, DeserializationContext ctxt) throws IOException { // Minor optimization to handle small lists (default size for ArrayList is 1

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>class); } } protected Object mapArray(JsonParser jp, DeserializationContext ctxt) throws IOException { Object value = deserialize(jp, ctxt); if (jp.nextToken() == JsonToken.END_ARRAY) { ArrayList<Object> l = new ArrayList<Object>(2); l.add(value); return l; } Object value2 = deserialize(jp, ctxt); if (jp.nextToken() == JsonToken.END_ARRAY) { ArrayList<Object> l = new ArrayList<Object>(2); l.add(value); l.add(value2); return l; } ObjectBuffer buffer = ctxt.leaseObjectBuffer(); Object[] values = buffer.resetAndStart(); int ptr = 0; values[ptr++] = value; values[ptr++] = value2; int totalSize = ptr; do { value = deserialize(jp, ctxt); ++totalSize; if (ptr >= values.length) { values = buffer.appendCompletedChunk(values); ptr = 0; } values[ptr++] = value; } while (jp.nextToken() != JsonToken.END_ARRAY); // let's create full array then ArrayList<Object> result = new ArrayList<Object>(totalSize); buffer.completeAndClearBuffer(values, ptr, result); return result; } /** * Method called to map a JSON Object into a Java value. */ protected Object mapObject(JsonParser jp, DeserializationContext ctxt) throws IOException { // will point to FIELD_NAME at this point, guaranteed String field1 = jp.getText(); jp.nextToken(); Object value1 = deserialize(jp, ctxt); if (jp.nextToken() == JsonToken.END_OBJECT) { // single entry; but we want modifiable LinkedHashMap<String, Object> result = new LinkedHashMap<String, Object>(2); result.put(field1, value1); return result; } String field2 = jp.getText(); jp.nextToken(); Object value2 = deserialize(jp, ctxt); if (jp.nextToken() == JsonToken.END_OBJECT) { LinkedHashMap<String, Object> result = new LinkedHashMap<String, Object>(4); result.put(field1

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>, value1); result.put(field2, value2); return result; } // And then the general case; default map size is 16 LinkedHashMap<String, Object> result = new LinkedHashMap<String, Object>(); result.put(field1, value1); result.put(field2, value2); do { String fieldName = jp.getText(); jp.nextToken(); result.put(fieldName, deserialize(jp, ctxt)); } while (jp.nextToken() != JsonToken.END_OBJECT); return result; } /** * Method called to map a JSON Array into a Java Object array (Object[]). */ protected Object[] mapArrayToArray(JsonParser jp, DeserializationContext ctxt) throws IOException { ObjectBuffer buffer = ctxt.leaseObjectBuffer(); Object[] values = buffer.resetAndStart(); int ptr = 0; do { Object value = deserialize(jp, ctxt); if (ptr >= values.length) { values = buffer.appendCompletedChunk(values); ptr = 0; } values[ptr++] = value; } while (jp.nextToken() != JsonToken.END_ARRAY); return buffer.completeAndClearBuffer(values, ptr); } } }

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>package com.fasterxml.jackson.databind.introspect; import java.lang.reflect.Method; import java.util.*; /** * Simple helper class used to keep track of collection of * {@link AnnotatedMethod}s, accessible by lookup. Lookup * is usually needed for augmenting and overriding annotations. */ public final class AnnotatedMethodMap implements Iterable<AnnotatedMethod> { protected LinkedHashMap<MemberKey,AnnotatedMethod> _methods; public AnnotatedMethodMap() { } /** * Method called to add specified annotated method in the Map. */ public void add(AnnotatedMethod am) { if (_methods == null) { _methods = new LinkedHashMap<MemberKey,AnnotatedMethod>(); } _methods.put(new MemberKey(am.getAnnotated()), am); } /** * Method called to remove specified method, assuming * it exists in the Map */ public AnnotatedMethod remove(AnnotatedMethod am) { return remove(am.getAnnotated()); } public AnnotatedMethod remove(Method m) { if (_methods != null) { return _methods.remove(new MemberKey(m)); } return null; } public boolean isEmpty() { return (_methods == null || _methods.size() == 0); } public int size() { return (_methods == null) ? 0 : _methods.size(); } public AnnotatedMethod find(String name, Class<?>[] paramTypes) { if (_methods == null) { return null; } return _methods.get(new MemberKey(name, paramTypes)); } public AnnotatedMethod find(Method m) { if (_methods == null) { return null; } return _methods.get(new MemberKey(m)); } /* /********************************************************** /* Iterable implementation (for iterating over values) /********************************************************** */ @Override public Iterator<AnnotatedMethod> iterator() { if (_methods != null) { return _methods.values().iterator(); } List<AnnotatedMethod> empty = Collections.emptyList(); return empty.iterator(); } }

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> type serializer is suggested, * we'll ignore it... */ @Override public ContainerSerializer<?> _withValueTypeSerializer(TypeSerializer vts) { return this; } /* /********************************************************** /* Post-processing /********************************************************** */ @Override public JsonSerializer<?> createContextual(SerializerProvider provider, BeanProperty property) throws JsonMappingException { /* 29-Sep-2012, tatu: Actually, we need to do much more contextual * checking here since we finally know for sure the property, * and it may have overrides */ JsonSerializer<?> ser = null; // First: if we have a property, may have property-annotation overrides if (property != null) { AnnotatedMember m = property.getMember(); if (m != null) { Object serDef = provider.getAnnotationIntrospector().findContentSerializer(m); if (serDef != null) { ser = provider.serializerInstance(m, serDef); } } } if (ser == null) { ser = _elementSerializer; } // #124: May have a content converter ser = findConvertingContentSerializer(provider, property, ser); if (ser == null) { ser = provider.findValueSerializer(String.class, property); } else { ser = provider.handleSecondaryContextualization(ser, property); } // Optimization: default serializer just writes String, so we can avoid a call: if (isDefaultSerializer(ser)) { ser = null; } // note: will never have TypeSerializer, because Strings are "natural" type if (ser == _elementSerializer) { return this; } return new StringArraySerializer(this, property, ser); } /* /********************************************************** /* Simple accessors /********************************************************** */ @Override public JavaType getContentType() { return VALUE_TYPE; } @Override public JsonSerializer<?> getContentSerializer() { return _elementSerializer; } @Override public boolean isEmpty(SerializerProvider prov, String[] value) { return (value == null) || (value.length == 0); } @Override public boolean hasSingleElement(String[] value) { return (value.length

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>serialize(value[i], jgen, provider); } } } @Override public JsonNode getSchema(SerializerProvider provider, Type typeHint) { return createSchemaNode("array", true).set("items", createSchemaNode("string")); } @Override public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) throws JsonMappingException { if (visitor != null) { JsonArrayFormatVisitor v2 = visitor.expectArrayFormat(typeHint); if (v2 != null) { v2.itemsFormat(JsonFormatTypes.STRING); } } } }

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> return true; } @Override public void serializeAsField(Object bean, JsonGenerator jgen, SerializerProvider prov) throws Exception { final Object value = get(bean); if (value == null) { // Hmmh. I assume we MUST pretty much suppress nulls, since we // can't really unwrap them... return; } JsonSerializer<Object> ser = _serializer; if (ser == null) { Class<?> cls = value.getClass(); PropertySerializerMap map = _dynamicSerializers; ser = map.serializerFor(cls); if (ser == null) { ser = _findAndAddDynamic(map, cls, prov); } } if (_suppressableValue != null) { if (MARKER_FOR_EMPTY == _suppressableValue) { if (ser.isEmpty(prov, value)) { return; } } else if (_suppressableValue.equals(value)) { return; } } // For non-nulls, first: simple check for direct cycles if (value == bean) { if (_handleSelfReference(bean, jgen, prov, ser)) { return; } } // note: must verify we are using unwrapping serializer; if not, will write field name if (!ser.isUnwrappingSerializer()) { jgen.writeFieldName(_name); } if (_typeSerializer == null) { ser.serialize(value, jgen, prov); } else { ser.serializeWithType(value, jgen, prov, _typeSerializer); } } // need to override as we must get unwrapping instance... @Override public void assignSerializer(JsonSerializer<Object> ser) { super.assignSerializer(ser); if (_serializer != null) { NameTransformer t = _nameTransformer; if (_serializer.isUnwrappingSerializer()) { t = NameTransformer.chainedTransformer(t, ((UnwrappingBeanSerializer) _serializer)._nameTransformer); } _serializer = _serializer.unwrappingSerializer(t); } } /* /********************************************************** /* Overrides: schema generation /********************************************************** */ @Override public void depositSchemaProperty(final JsonObjectFormatVisitor visitor) throws JsonMappingException { SerializerProvider provider = visitor.

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>getProvider(); JsonSerializer<Object> ser = provider .findValueSerializer(this.getType(), this) .unwrappingSerializer(_nameTransformer); if (ser.isUnwrappingSerializer()) { ser.acceptJsonFormatVisitor(new JsonFormatVisitorWrapper.Base(provider) { // an unwrapping serializer will always expect ObjectFormat, // hence, the other cases do not have to be implemented @Override public JsonObjectFormatVisitor expectObjectFormat(JavaType type) throws JsonMappingException { return visitor; } }, this.getType()); } else { super.depositSchemaProperty(visitor); } } // Override needed to support legacy JSON Schema generator @Override protected void _depositSchemaProperty(ObjectNode propertiesNode, JsonNode schemaNode) { JsonNode props = schemaNode.get("properties"); if (props != null) { Iterator<Entry<String, JsonNode>> it = props.fields(); while (it.hasNext()) { Entry<String,JsonNode> entry = it.next(); String name = entry.getKey(); if (_nameTransformer != null) { name = _nameTransformer.transform(name); } propertiesNode.set(name, entry.getValue()); } } } /* /********************************************************** /* Overrides: internal, other /********************************************************** */ // need to override as we must get unwrapping instance... @Override protected JsonSerializer<Object> _findAndAddDynamic(PropertySerializerMap map, Class<?> type, SerializerProvider provider) throws JsonMappingException { JsonSerializer<Object> serializer; if (_nonTrivialBaseType != null) { JavaType subtype = provider.constructSpecializedType(_nonTrivialBaseType, type); serializer = provider.findValueSerializer(subtype, this); } else { serializer = provider.findValueSerializer(type, this); } NameTransformer t = _nameTransformer; if (serializer.isUnwrappingSerializer()) { t = NameTransformer.chainedTransformer(t, ((UnwrappingBeanSerializer) serializer)._nameTransformer); } serializer = serializer.unwrappingSerializer(t); _dynamicSerializers = _dynamicSerializers.newWith(type, serializer); return serializer; } }

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> immutable, you can NOT change settings * by accessing an instance and calling methods: this will simply create * new instance of factory object. */ public SerializerFactory getSerializerFactory() { return _serializerFactory; } /** * Method for setting specific {@link SerializerProvider} to use * for handling caching of {@link JsonSerializer} instances. */ public ObjectMapper setSerializerProvider(DefaultSerializerProvider p) { _serializerProvider = p; return this; } public SerializerProvider getSerializerProvider() { return _serializerProvider; } /* /********************************************************** /* Configuration: mix-in annotations /********************************************************** */ /** * Method to use for defining mix-in annotations to use for augmenting * annotations that processable (serializable / deserializable) * classes have. * Mixing in is done when introspecting class annotations and properties. * Map passed contains keys that are target classes (ones to augment * with new annotation overrides), and values that are source classes * (have annotations to use for augmentation). * Annotations from source classes (and their supertypes) * will <b>override</b> * annotations that target classes (and their super-types) have. * * @since 2.5 */ public ObjectMapper setMixIns(Map<Class<?>, Class<?>> sourceMixins) { _mixInAnnotations.clear(); if (sourceMixins != null && sourceMixins.size() > 0) { for (Map.Entry<Class<?>,Class<?>> en : sourceMixins.entrySet()) { _mixInAnnotations.put(new ClassKey(en.getKey()), en.getValue()); } } return this; } /** * Method to use for adding mix-in annotations to use for augmenting * specified class or interface. All annotations from * <code>mixinSource</code> are taken to override annotations * that <code>target</code> (or its supertypes) has. * * @param target Class (or interface) whose annotations to effectively override * @param mixinSource Class (or interface) whose annotations are to * be "added" to target's annotations, overriding as necessary * * @since 2.5 */ public ObjectMapper addMixIn(

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>Class<?> target, Class<?> mixinSource) { _mixInAnnotations.put(new ClassKey(target), mixinSource); return this; } public Class<?> findMixInClassFor(Class<?> cls) { return (_mixInAnnotations == null) ? null : _mixInAnnotations.get(new ClassKey(cls)); } public int mixInCount() { return (_mixInAnnotations == null) ? 0 : _mixInAnnotations.size(); } /** * @deprecated Since 2.5: replaced by a fluent form of the method; {@link #setMixIns}. */ @Deprecated public void setMixInAnnotations(Map<Class<?>, Class<?>> sourceMixins) { setMixIns(sourceMixins); } /** * @deprecated Since 2.5: replaced by a fluent form of the method; {@link #addMixIn(Class, Class)}. */ @Deprecated public final void addMixInAnnotations(Class<?> target, Class<?> mixinSource) { addMixIn(target, mixinSource); } /* /********************************************************** /* Configuration, introspection /********************************************************** */ /** * Method for accessing currently configured visibility checker; * object used for determining whether given property element * (method, field, constructor) can be auto-detected or not. */ public VisibilityChecker<?> getVisibilityChecker() { return _serializationConfig.getDefaultVisibilityChecker(); } /** * Method for setting currently configured visibility checker; * object used for determining whether given property element * (method, field, constructor) can be auto-detected or not. * This default checker is used if no per-class overrides * are defined. */ public void setVisibilityChecker(VisibilityChecker<?> vc) { _deserializationConfig = _deserializationConfig.with(vc); _serializationConfig = _serializationConfig.with(vc); } /** * Convenience method that allows changing configuration for * underlying {@link VisibilityChecker}s, to change details of what kinds of * properties are auto-detected. * Basically short cut for doing: *<pre> * mapper.setVisibilityChecker( * mapper.getVisibilityChecker().withVisibility(forMethod, visibility) * ); *</pre> * one common use

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> a bean, array * or a wrapper type (like {@link java.lang.Boolean}). *<p> * Note: this method should NOT be used if the result type is a * container ({@link java.util.Collection} or {@link java.util.Map}. * The reason is that due to type erasure, key and value types * can not be introspected when using this method. * * @throws IOException if a low-level I/O problem (unexpected end-of-input, * network error) occurs (passed through as-is without additional wrapping -- note * that this is one case where {@link DeserializationFeature#WRAP_EXCEPTIONS} * does NOT result in wrapping of exception even if enabled) * @throws JsonParseException if underlying input contains invalid content * of type {@link JsonParser} supports (JSON for default case) * @throws JsonMappingException if the input JSON structure does not match structure * expected for result type (or has other mismatch issues) */ @Override @SuppressWarnings("unchecked") public <T> T readValue(JsonParser jp, Class<T> valueType) throws IOException, JsonParseException, JsonMappingException { return (T) _readValue(getDeserializationConfig(), jp, _typeFactory.constructType(valueType)); } /** * Method to deserialize JSON content into a Java type, reference * to which is passed as argument. Type is passed using so-called * "super type token" (see ) * and specifically needs to be used if the root type is a * parameterized (generic) container type. * * @throws IOException if a low-level I/O problem (unexpected end-of-input, * network error) occurs (passed through as-is without additional wrapping -- note * that this is one case where {@link DeserializationFeature#WRAP_EXCEPTIONS} * does NOT result in wrapping of exception even if enabled) * @throws JsonParseException if underlying input contains invalid content * of type {@link JsonParser} supports (JSON for default case) * @throws JsonMappingException if the input JSON structure does not match structure * expected for result type (or has other mismatch issues) */ @Override @SuppressWarnings("unchecked") public <T

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>> T readValue(JsonParser jp, TypeReference<?> valueTypeRef) throws IOException, JsonParseException, JsonMappingException { return (T) _readValue(getDeserializationConfig(), jp, _typeFactory.constructType(valueTypeRef)); } /** * Method to deserialize JSON content into a Java type, reference * to which is passed as argument. Type is passed using * Jackson specific type; instance of which can be constructed using * {@link TypeFactory}. * * @throws IOException if a low-level I/O problem (unexpected end-of-input, * network error) occurs (passed through as-is without additional wrapping -- note * that this is one case where {@link DeserializationFeature#WRAP_EXCEPTIONS} * does NOT result in wrapping of exception even if enabled) * @throws JsonParseException if underlying input contains invalid content * of type {@link JsonParser} supports (JSON for default case) * @throws JsonMappingException if the input JSON structure does not match structure * expected for result type (or has other mismatch issues) */ @Override @SuppressWarnings("unchecked") public final <T> T readValue(JsonParser jp, ResolvedType valueType) throws IOException, JsonParseException, JsonMappingException { return (T) _readValue(getDeserializationConfig(), jp, (JavaType) valueType); } /** * Type-safe overloaded method, basically alias for {@link #readValue(JsonParser, Class)}. * * @throws IOException if a low-level I/O problem (unexpected end-of-input, * network error) occurs (passed through as-is without additional wrapping -- note * that this is one case where {@link DeserializationFeature#WRAP_EXCEPTIONS} * does NOT result in wrapping of exception even if enabled) * @throws JsonParseException if underlying input contains invalid content * of type {@link JsonParser} supports (JSON for default case) * @throws JsonMappingException if the input JSON structure does not match structure * expected for result type (or has other mismatch issues) */ @SuppressWarnings("unchecked") public <T> T readValue(JsonParser jp, JavaType valueType) throws IOException, JsonParseException, JsonMappingException { return (T) _readValue(get

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> */ public JsonNode readTree(File file) throws IOException, JsonProcessingException { JsonNode n = (JsonNode) _readMapAndClose(_jsonFactory.createParser(file), JSON_NODE_TYPE); return (n == null) ? NullNode.instance : n; } /** * Method to deserialize JSON content as tree expressed using set of {@link JsonNode} instances. * Returns root of the resulting tree (where root can consist of just a single node if the current * event is a value event, not container). * * @param source URL to use for fetching contents to parse as JSON for building a tree instance * * @return a {@link JsonNode}, if valid JSON content found; null * if input has no content to bind -- note, however, that if * JSON <code>null</code> token is found, it will be represented * as a non-null {@link JsonNode} (one that returns <code>true</code> * for {@link JsonNode#isNull()} * * @throws IOException if a low-level I/O problem (unexpected end-of-input, * network error) occurs (passed through as-is without additional wrapping -- note * that this is one case where {@link DeserializationFeature#WRAP_EXCEPTIONS} * does NOT result in wrapping of exception even if enabled) * @throws JsonParseException if underlying input contains invalid content * of type {@link JsonParser} supports (JSON for default case) */ public JsonNode readTree(URL source) throws IOException, JsonProcessingException { JsonNode n = (JsonNode) _readMapAndClose(_jsonFactory.createParser(source), JSON_NODE_TYPE); return (n == null) ? NullNode.instance : n; } /* /********************************************************** /* Public API (from ObjectCodec): serialization /* (mapping from Java types to Json) /********************************************************** */ /** * Method that can be used to serialize any Java value as * JSON output, using provided {@link JsonGenerator}. */ @Override public void writeValue(JsonGenerator jgen, Object value) throws IOException, JsonGenerationException, JsonMappingException { SerializationConfig config = getSerializationConfig(); // 10-Aug-2012, tatu

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS></b>: in case an exception is thrown during course of trying * co construct matching deserializer, it will be effectively swallowed. * If you want access to that exception, call * {@link #canDeserialize(JavaType, AtomicReference)} instead. * * @return True if mapper can find a serializer for instances of * given class (potentially serializable), false otherwise (not * serializable) */ public boolean canDeserialize(JavaType type) { return createDeserializationContext(null, getDeserializationConfig()).hasValueDeserializerFor(type, null); } /** * Method similar to {@link #canDeserialize(JavaType)} but that can return * actual {@link Throwable} that was thrown when trying to construct * serializer: this may be useful in figuring out what the actual problem is. * * @since 2.3 */ public boolean canDeserialize(JavaType type, AtomicReference<Throwable> cause) { return createDeserializationContext(null, getDeserializationConfig()).hasValueDeserializerFor(type, cause); } /* /********************************************************** /* Extended Public API, deserialization, /* convenience methods /********************************************************** */ /** * Method to deserialize JSON content from given file into given Java type. * * @throws IOException if a low-level I/O problem (unexpected end-of-input, * network error) occurs (passed through as-is without additional wrapping -- note * that this is one case where {@link DeserializationFeature#WRAP_EXCEPTIONS} * does NOT result in wrapping of exception even if enabled) * @throws JsonParseException if underlying input contains invalid content * of type {@link JsonParser} supports (JSON for default case) * @throws JsonMappingException if the input JSON structure does not match structure * expected for result type (or has other mismatch issues) */ @SuppressWarnings("unchecked") public <T> T readValue(File src, Class<T> valueType) throws IOException, JsonParseException, JsonMappingException { return (T) _readMapAndClose(_jsonFactory.createParser(src), _typeFactory.constructType(valueType)); } /** * Method to deserialize JSON content from given file into given Java type. * * @throws IOException if a low-

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>level I/O problem (unexpected end-of-input, * network error) occurs (passed through as-is without additional wrapping -- note * that this is one case where {@link DeserializationFeature#WRAP_EXCEPTIONS} * does NOT result in wrapping of exception even if enabled) * @throws JsonParseException if underlying input contains invalid content * of type {@link JsonParser} supports (JSON for default case) * @throws JsonMappingException if the input JSON structure does not match structure * expected for result type (or has other mismatch issues) */ @SuppressWarnings({ "unchecked", "rawtypes" }) public <T> T readValue(File src, TypeReference valueTypeRef) throws IOException, JsonParseException, JsonMappingException { return (T) _readMapAndClose(_jsonFactory.createParser(src), _typeFactory.constructType(valueTypeRef)); } /** * Method to deserialize JSON content from given file into given Java type. * * @throws IOException if a low-level I/O problem (unexpected end-of-input, * network error) occurs (passed through as-is without additional wrapping -- note * that this is one case where {@link DeserializationFeature#WRAP_EXCEPTIONS} * does NOT result in wrapping of exception even if enabled) * @throws JsonParseException if underlying input contains invalid content * of type {@link JsonParser} supports (JSON for default case) * @throws JsonMappingException if the input JSON structure does not match structure * expected for result type (or has other mismatch issues) */ @SuppressWarnings("unchecked") public <T> T readValue(File src, JavaType valueType) throws IOException, JsonParseException, JsonMappingException { return (T) _readMapAndClose(_jsonFactory.createParser(src), valueType); } /** * Method to deserialize JSON content from given resource into given Java type. * * @throws IOException if a low-level I/O problem (unexpected end-of-input, * network error) occurs (passed through as-is without additional wrapping -- note * that this is one case where {@link DeserializationFeature#WRAP_EXCEPTIONS} * does NOT result in wrapping of exception even if enabled) * @throws

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> JsonParseException if underlying input contains invalid content * of type {@link JsonParser} supports (JSON for default case) * @throws JsonMappingException if the input JSON structure does not match structure * expected for result type (or has other mismatch issues) */ @SuppressWarnings("unchecked") public <T> T readValue(URL src, Class<T> valueType) throws IOException, JsonParseException, JsonMappingException { // !!! TODO // _setupClassLoaderForDeserialization(valueType); return (T) _readMapAndClose(_jsonFactory.createParser(src), _typeFactory.constructType(valueType)); } /** * Method to deserialize JSON content from given resource into given Java type. * * @throws IOException if a low-level I/O problem (unexpected end-of-input, * network error) occurs (passed through as-is without additional wrapping -- note * that this is one case where {@link DeserializationFeature#WRAP_EXCEPTIONS} * does NOT result in wrapping of exception even if enabled) * @throws JsonParseException if underlying input contains invalid content * of type {@link JsonParser} supports (JSON for default case) * @throws JsonMappingException if the input JSON structure does not match structure * expected for result type (or has other mismatch issues) */ @SuppressWarnings({ "unchecked", "rawtypes" }) public <T> T readValue(URL src, TypeReference valueTypeRef) throws IOException, JsonParseException, JsonMappingException { return (T) _readMapAndClose(_jsonFactory.createParser(src), _typeFactory.constructType(valueTypeRef)); } @SuppressWarnings("unchecked") public <T> T readValue(URL src, JavaType valueType) throws IOException, JsonParseException, JsonMappingException { return (T) _readMapAndClose(_jsonFactory.createParser(src), valueType); } /** * Method to deserialize JSON content from given JSON content String. * * @throws IOException if a low-level I/O problem (unexpected end-of-input, * network error) occurs (passed through as-is without additional wrapping -- note * that this is one case where {@link DeserializationFeature#WRAP_EXCEPTIONS} * does NOT result

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> in wrapping of exception even if enabled) * @throws JsonParseException if underlying input contains invalid content * of type {@link JsonParser} supports (JSON for default case) * @throws JsonMappingException if the input JSON structure does not match structure * expected for result type (or has other mismatch issues) */ @SuppressWarnings("unchecked") public <T> T readValue(String content, Class<T> valueType) throws IOException, JsonParseException, JsonMappingException { // !!! TODO // _setupClassLoaderForDeserialization(valueType); return (T) _readMapAndClose(_jsonFactory.createParser(content), _typeFactory.constructType(valueType)); } /** * Method to deserialize JSON content from given JSON content String. * * @throws IOException if a low-level I/O problem (unexpected end-of-input, * network error) occurs (passed through as-is without additional wrapping -- note * that this is one case where {@link DeserializationFeature#WRAP_EXCEPTIONS} * does NOT result in wrapping of exception even if enabled) * @throws JsonParseException if underlying input contains invalid content * of type {@link JsonParser} supports (JSON for default case) * @throws JsonMappingException if the input JSON structure does not match structure * expected for result type (or has other mismatch issues) */ @SuppressWarnings({ "unchecked", "rawtypes" }) public <T> T readValue(String content, TypeReference valueTypeRef) throws IOException, JsonParseException, JsonMappingException { return (T) _readMapAndClose(_jsonFactory.createParser(content), _typeFactory.constructType(valueTypeRef)); } /** * Method to deserialize JSON content from given JSON content String. * * @throws IOException if a low-level I/O problem (unexpected end-of-input, * network error) occurs (passed through as-is without additional wrapping -- note * that this is one case where {@link DeserializationFeature#WRAP_EXCEPTIONS} * does NOT result in wrapping of exception even if enabled) * @throws JsonParseException if underlying input contains invalid content * of type {@link JsonParser} supports (JSON for default case) * @throws JsonMappingException if the input JSON structure

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> does not match structure * expected for result type (or has other mismatch issues) */ @SuppressWarnings("unchecked") public <T> T readValue(String content, JavaType valueType) throws IOException, JsonParseException, JsonMappingException { return (T) _readMapAndClose(_jsonFactory.createParser(content), valueType); } @SuppressWarnings("unchecked") public <T> T readValue(Reader src, Class<T> valueType) throws IOException, JsonParseException, JsonMappingException { // !!! TODO // _setupClassLoaderForDeserialization(valueType); return (T) _readMapAndClose(_jsonFactory.createParser(src), _typeFactory.constructType(valueType)); } @SuppressWarnings({ "unchecked", "rawtypes" }) public <T> T readValue(Reader src, TypeReference valueTypeRef) throws IOException, JsonParseException, JsonMappingException { return (T) _readMapAndClose(_jsonFactory.createParser(src), _typeFactory.constructType(valueTypeRef)); } @SuppressWarnings("unchecked") public <T> T readValue(Reader src, JavaType valueType) throws IOException, JsonParseException, JsonMappingException { return (T) _readMapAndClose(_jsonFactory.createParser(src), valueType); } @SuppressWarnings("unchecked") public <T> T readValue(InputStream src, Class<T> valueType) throws IOException, JsonParseException, JsonMappingException { // !!! TODO // _setupClassLoaderForDeserialization(valueType); return (T) _readMapAndClose(_jsonFactory.createParser(src), _typeFactory.constructType(valueType)); } @SuppressWarnings({ "unchecked", "rawtypes" }) public <T> T readValue(InputStream src, TypeReference valueTypeRef) throws IOException, JsonParseException, JsonMappingException { return (T) _readMapAndClose(_jsonFactory.createParser(src), _typeFactory.constructType(valueTypeRef)); } @SuppressWarnings("unchecked") public <T> T readValue(InputStream src, JavaType valueType) throws IOException, JsonParseException, JsonMappingException { return (T) _readMapAndClose(_jsonFactory.createParser(src), valueType); }

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> @SuppressWarnings("unchecked") public <T> T readValue(byte[] src, Class<T> valueType) throws IOException, JsonParseException, JsonMappingException { // !!! TODO // _setupClassLoaderForDeserialization(valueType); return (T) _readMapAndClose(_jsonFactory.createParser(src), _typeFactory.constructType(valueType)); } @SuppressWarnings("unchecked") public <T> T readValue(byte[] src, int offset, int len, Class<T> valueType) throws IOException, JsonParseException, JsonMappingException { // !!! TODO // _setupClassLoaderForDeserialization(valueType); return (T) _readMapAndClose(_jsonFactory.createParser(src, offset, len), _typeFactory.constructType(valueType)); } @SuppressWarnings({ "unchecked", "rawtypes" }) public <T> T readValue(byte[] src, TypeReference valueTypeRef) throws IOException, JsonParseException, JsonMappingException { return (T) _readMapAndClose(_jsonFactory.createParser(src), _typeFactory.constructType(valueTypeRef)); } @SuppressWarnings({ "unchecked", "rawtypes" }) public <T> T readValue(byte[] src, int offset, int len, TypeReference valueTypeRef) throws IOException, JsonParseException, JsonMappingException { return (T) _readMapAndClose(_jsonFactory.createParser(src, offset, len), _typeFactory.constructType(valueTypeRef)); } @SuppressWarnings("unchecked") public <T> T readValue(byte[] src, JavaType valueType) throws IOException, JsonParseException, JsonMappingException { return (T) _readMapAndClose(_jsonFactory.createParser(src), valueType); } @SuppressWarnings("unchecked") public <T> T readValue(byte[] src, int offset, int len, JavaType valueType) throws IOException, JsonParseException, JsonMappingException { return (T) _readMapAndClose(_jsonFactory.createParser(src, offset, len), valueType); } /* /********************************************************** /* Extended Public API: serialization /* (mapping from Java types to JSON) /********************************************************** */ /** * Method that can be used to serialize

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> any Java value as * JSON output, written to File provided. */ public void writeValue(File resultFile, Object value) throws IOException, JsonGenerationException, JsonMappingException { _configAndWriteValue(_jsonFactory.createGenerator(resultFile, JsonEncoding.UTF8), value); } /** * Method that can be used to serialize any Java value as * JSON output, using output stream provided (using encoding * {@link JsonEncoding#UTF8}). *<p> * Note: method does not close the underlying stream explicitly * here; however, {@link JsonFactory} this mapper uses may choose * to close the stream depending on its settings (by default, * it will try to close it when {@link JsonGenerator} we construct * is closed). */ public void writeValue(OutputStream out, Object value) throws IOException, JsonGenerationException, JsonMappingException { _configAndWriteValue(_jsonFactory.createGenerator(out, JsonEncoding.UTF8), value); } /** * Method that can be used to serialize any Java value as * JSON output, using Writer provided. *<p> * Note: method does not close the underlying stream explicitly * here; however, {@link JsonFactory} this mapper uses may choose * to close the stream depending on its settings (by default, * it will try to close it when {@link JsonGenerator} we construct * is closed). */ public void writeValue(Writer w, Object value) throws IOException, JsonGenerationException, JsonMappingException { _configAndWriteValue(_jsonFactory.createGenerator(w), value); } /** * Method that can be used to serialize any Java value as * a String. Functionally equivalent to calling * {@link #writeValue(Writer,Object)} with {@link java.io.StringWriter} * and constructing String, but more efficient. *<p> * Note: prior to version 2.1, throws clause included {@link IOException}; 2.1 removed it. */ @SuppressWarnings("resource") public String writeValueAsString(Object value) throws JsonProcessingException { // alas, we have to pull the recycler directly here... SegmentedStringWriter sw = new SegmentedStringWriter(_jsonFactory._getBufferRecycler());

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> try { _configAndWriteValue(_jsonFactory.createGenerator(sw), value); } catch (JsonProcessingException e) { // to support [JACKSON-758] throw e; } catch (IOException e) { // shouldn't really happen, but is declared as possibility so: throw JsonMappingException.fromUnexpectedIOE(e); } return sw.getAndClear(); } /** * Method that can be used to serialize any Java value as * a byte array. Functionally equivalent to calling * {@link #writeValue(Writer,Object)} with {@link java.io.ByteArrayOutputStream} * and getting bytes, but more efficient. * Encoding used will be UTF-8. *<p> * Note: prior to version 2.1, throws clause included {@link IOException}; 2.1 removed it. */ @SuppressWarnings("resource") public byte[] writeValueAsBytes(Object value) throws JsonProcessingException { ByteArrayBuilder bb = new ByteArrayBuilder(_jsonFactory._getBufferRecycler()); try { _configAndWriteValue(_jsonFactory.createGenerator(bb, JsonEncoding.UTF8), value); } catch (JsonProcessingException e) { // to support [JACKSON-758] throw e; } catch (IOException e) { // shouldn't really happen, but is declared as possibility so: throw JsonMappingException.fromUnexpectedIOE(e); } byte[] result = bb.toByteArray(); bb.release(); return result; } /* /********************************************************** /* Extended Public API: constructing ObjectWriters /* for more advanced configuration /********************************************************** */ /** * Convenience method for constructing {@link ObjectWriter} * with default settings. */ @SuppressWarnings("unchecked") public <W extends ObjectWriter> W writer() { return (W) _newWriter(getSerializationConfig()); } /** * Factory method for constructing {@link ObjectWriter} with * specified feature enabled (compared to settings that this * mapper instance has). */ @SuppressWarnings("unchecked") public <W extends ObjectWriter> W writer(SerializationFeature feature) { return (W) _newWriter(getSerializationConfig().with(feature)); } /** * Factory method for constructing {@link ObjectWriter

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> _serializerProvider(config).serializeValue(buf, fromValue); // then matching read, inlined 'readValue' with minor mods: final JsonParser jp = buf.asParser(); Object result; // ok to pass in existing feature flags; unwrapping handled by mapper final DeserializationConfig deserConfig = getDeserializationConfig(); JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL) { DeserializationContext ctxt = createDeserializationContext(jp, deserConfig); result = _findRootDeserializer(ctxt, toValueType).getNullValue(); } else if (t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = null; } else { // pointing to event other than null DeserializationContext ctxt = createDeserializationContext(jp, deserConfig); JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, toValueType); // note: no handling of unwarpping result = deser.deserialize(jp, ctxt); } jp.close(); return result; } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } } /* /********************************************************** /* Extended Public API: JSON Schema generation /********************************************************** */ /** * Generate <a href="http://json-schema.org/">Json-schema</a> * instance for specified class. * * @param t The class to generate schema for * @return Constructed JSON schema. */ @SuppressWarnings("deprecation") public com.fasterxml.jackson.databind.jsonschema.JsonSchema generateJsonSchema(Class<?> t) throws JsonMappingException { return _serializerProvider(getSerializationConfig()).generateJsonSchema(t); } /** * Method for visiting type hierarchy for given type, using specified visitor. *<p> * This method can be used for things like * generating <a href="http://json-schema.org/">Json Schema</a> * instance for specified type. * * @param type Type to generate schema for (possibly with generic signature) * * @since 2.1 */ public void acceptJsonFormatVisitor(Class<?> type, JsonFormatVisitorWrapper visitor) throws JsonMappingException

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> { acceptJsonFormatVisitor(_typeFactory.constructType(type), visitor); } /** * Method for visiting type hierarchy for given type, using specified visitor. * Visitation uses <code>Serializer</code> hierarchy and related properties *<p> * This method can be used for things like * generating <a href="http://json-schema.org/">Json Schema</a> * instance for specified type. * * @param type Type to generate schema for (possibly with generic signature) * * @since 2.1 */ public void acceptJsonFormatVisitor(JavaType type, JsonFormatVisitorWrapper visitor) throws JsonMappingException { if (type == null) { throw new IllegalArgumentException("type must be provided"); } _serializerProvider(getSerializationConfig()).acceptJsonFormatVisitor(type, visitor); } /* /********************************************************** /* Internal methods for serialization, overridable /********************************************************** */ /** * Overridable helper method used for constructing * {@link SerializerProvider} to use for serialization. */ protected DefaultSerializerProvider _serializerProvider(SerializationConfig config) { return _serializerProvider.createInstance(config, _serializerFactory); } /** * Helper method that should return default pretty-printer to * use for generators constructed by this mapper, when instructed * to use default pretty printer. */ protected PrettyPrinter _defaultPrettyPrinter() { return _defaultPrettyPrinter; } /** * Method called to configure the generator as necessary and then * call write functionality */ protected final void _configAndWriteValue(JsonGenerator jgen, Object value) throws IOException { SerializationConfig cfg = getSerializationConfig(); cfg.initialize(jgen); // since 2.5 if (cfg.isEnabled(SerializationFeature.CLOSE_CLOSEABLE) && (value instanceof Closeable)) { _configAndWriteCloseable(jgen, value, cfg); return; } boolean closed = false; try { _serializerProvider(cfg).serializeValue(jgen, value); closed = true; jgen.close(); } finally { /* won't try to close twice; also, must catch exception (so it * will not mask exception that is pending) */ if (!closed) { /*

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>04-Mar-2014, tatu: But! Let's try to prevent auto-closing of * structures, which typically causes more damage. */ jgen.disable(JsonGenerator.Feature.AUTO_CLOSE_JSON_CONTENT); try { jgen.close(); } catch (IOException ioe) { } } } } protected final void _configAndWriteValue(JsonGenerator jgen, Object value, Class<?> viewClass) throws IOException { SerializationConfig cfg = getSerializationConfig().withView(viewClass); cfg.initialize(jgen); // since 2.5 // [JACKSON-282]: consider Closeable if (cfg.isEnabled(SerializationFeature.CLOSE_CLOSEABLE) && (value instanceof Closeable)) { _configAndWriteCloseable(jgen, value, cfg); return; } boolean closed = false; try { _serializerProvider(cfg).serializeValue(jgen, value); closed = true; jgen.close(); } finally { if (!closed) { // 04-Mar-2014, tatu: But! Let's try to prevent auto-closing of // structures, which typically causes more damage. jgen.disable(JsonGenerator.Feature.AUTO_CLOSE_JSON_CONTENT); try { jgen.close(); } catch (IOException ioe) { } } } } /** * Helper method used when value to serialize is {@link Closeable} and its <code>close()</code> * method is to be called right after serialization has been called */ private final void _configAndWriteCloseable(JsonGenerator jgen, Object value, SerializationConfig cfg) throws IOException, JsonGenerationException, JsonMappingException { Closeable toClose = (Closeable) value; try { _serializerProvider(cfg).serializeValue(jgen, value); JsonGenerator tmpJgen = jgen; jgen = null; tmpJgen.close(); Closeable tmpToClose = toClose; toClose = null; tmpToClose.close(); } finally { /* Need to close both generator and value, as long as they haven't yet * been closed */ if (jgen != null) {

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> // 04-Mar-2014, tatu: But! Let's try to prevent auto-closing of // structures, which typically causes more damage. jgen.disable(JsonGenerator.Feature.AUTO_CLOSE_JSON_CONTENT); try { jgen.close(); } catch (IOException ioe) { } } if (toClose != null) { try { toClose.close(); } catch (IOException ioe) { } } } } /** * Helper method used when value to serialize is {@link Closeable} and its <code>close()</code> * method is to be called right after serialization has been called */ private final void _writeCloseableValue(JsonGenerator jgen, Object value, SerializationConfig cfg) throws IOException, JsonGenerationException, JsonMappingException { Closeable toClose = (Closeable) value; try { _serializerProvider(cfg).serializeValue(jgen, value); if (cfg.isEnabled(SerializationFeature.FLUSH_AFTER_WRITE_VALUE)) { jgen.flush(); } Closeable tmpToClose = toClose; toClose = null; tmpToClose.close(); } finally { if (toClose != null) { try { toClose.close(); } catch (IOException ioe) { } } } } /* /********************************************************** /* Internal methods for deserialization, overridable /********************************************************** */ /** * Internal helper method called to create an instance of {@link DeserializationContext} * for deserializing a single root value. * Can be overridden if a custom context is needed. */ protected DefaultDeserializationContext createDeserializationContext(JsonParser jp, DeserializationConfig cfg) { return _deserializationContext.createInstance(cfg, jp, _injectableValues); } /** * Actual implementation of value reading+binding operation. */ protected Object _readValue(DeserializationConfig cfg, JsonParser jp, JavaType valueType) throws IOException, JsonParseException, JsonMappingException { /* First: may need to read the next token, to initialize * state (either before first read from parser, or after * previous token has been cleared) */ Object result; JsonToken t = _initForReading(jp);

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> if (t == JsonToken.VALUE_NULL) { // [JACKSON-643]: Ask JsonDeserializer what 'null value' to use: DeserializationContext ctxt = createDeserializationContext(jp, cfg); result = _findRootDeserializer(ctxt, valueType).getNullValue(); } else if (t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = null; } else { // pointing to event other than null DeserializationContext ctxt = createDeserializationContext(jp, cfg); JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, valueType); // ok, let's get the value if (cfg.useRootWrapping()) { result = _unwrapAndDeserialize(jp, ctxt, cfg, valueType, deser); } else { result = deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } protected Object _readMapAndClose(JsonParser jp, JavaType valueType) throws IOException, JsonParseException, JsonMappingException { try { Object result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL) { // [JACKSON-643]: Ask JsonDeserializer what 'null value' to use: DeserializationContext ctxt = createDeserializationContext(jp, getDeserializationConfig()); result = _findRootDeserializer(ctxt, valueType).getNullValue(); } else if (t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = null; } else { DeserializationConfig cfg = getDeserializationConfig(); DeserializationContext ctxt = createDeserializationContext(jp, cfg); JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, valueType); if (cfg.useRootWrapping()) { result = _unwrapAndDeserialize(jp, ctxt, cfg, valueType, deser); } else { result = deser.deserialize(jp, ctxt); } ctxt.checkUnresolvedObjectId(); } // Need to consume the token too jp.clearCurrentToken(); return result; } finally { try { jp.close(); } catch (IOException ioe) { } }

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> } /** * Method called to ensure that given parser is ready for reading * content for data binding. * * @return First token to be used for data binding after this call: * can never be null as exception will be thrown if parser can not * provide more tokens. * * @throws IOException if the underlying input source has problems during * parsing * @throws JsonParseException if parser has problems parsing content * @throws JsonMappingException if the parser does not have any more * content to map (note: Json "null" value is considered content; * enf-of-stream not) */ protected JsonToken _initForReading(JsonParser p) throws IOException { _deserializationConfig.initialize(p); // since 2.5 /* First: must point to a token; if not pointing to one, advance. * This occurs before first read from JsonParser, as well as * after clearing of current token. */ JsonToken t = p.getCurrentToken(); if (t == null) { // and then we must get something... t = p.nextToken(); if (t == null) { /* [JACKSON-546] Throw mapping exception, since it's failure to map, * not an actual parsing problem */ throw JsonMappingException.from(p, "No content to map due to end-of-input"); } } return t; } protected Object _unwrapAndDeserialize(JsonParser p, DeserializationContext ctxt, DeserializationConfig config, JavaType rootType, JsonDeserializer<Object> deser) throws IOException { String expName = config.getRootName(); if (expName == null) { PropertyName pname = _rootNames.findRootName(rootType, config); expName = pname.getSimpleName(); } if (p.getCurrentToken() != JsonToken.START_OBJECT) { throw JsonMappingException.from(p, "Current token not START_OBJECT (needed to unwrap root name '" +expName+"'), but "+p.getCurrentToken()); } if (p.nextToken() != JsonToken.FIELD_NAME) { throw JsonMappingException.from(p, "Current token not FIELD_NAME (to contain expected root name '" +

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>expName+"'), but "+p.getCurrentToken()); } String actualName = p.getCurrentName(); if (!expName.equals(actualName)) { throw JsonMappingException.from(p, "Root name '"+actualName+"' does not match expected ('" +expName+"') for type "+rootType); } // ok, then move to value itself.... p.nextToken(); Object result = deser.deserialize(p, ctxt); // and last, verify that we now get matching END_OBJECT if (p.nextToken() != JsonToken.END_OBJECT) { throw JsonMappingException.from(p, "Current token not END_OBJECT (to match wrapper object with root name '" +expName+"'), but "+p.getCurrentToken()); } return result; } /* /********************************************************** /* Internal methods, other /********************************************************** */ /** * Method called to locate deserializer for the passed root-level value. */ protected JsonDeserializer<Object> _findRootDeserializer(DeserializationContext ctxt, JavaType valueType) throws JsonMappingException { // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.2 */ protected void _verifySchemaType(FormatSchema schema) { if (schema != null) { if (!_jsonFactory.canUseSchema(schema)) { throw new IllegalArgumentException("Can not use FormatSchema of type "+schema.getClass().getName() +" for format "+_jsonFactory.getFormatName()); } } } }

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>package com.fasterxml.jackson.databind.jsonFormatVisitors; import com.fasterxml.jackson.databind.JavaType; import com.fasterxml.jackson.databind.JsonMappingException; /** * Interface {@link com.fasterxml.jackson.databind.JsonSerializer} implements * to allow for visiting type hierarchy. */ public interface JsonFormatVisitable { /** * Get the representation of the schema to which this serializer will conform. * * @param typeHint Type of element (entity like property) being visited */ public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) throws JsonMappingException; }

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> should be used instead. */ public final JsonParser getParser() { return _parser; } public final Object findInjectableValue(Object valueId, BeanProperty forProperty, Object beanInstance) { if (_injectableValues == null) { throw new IllegalStateException("No 'injectableValues' configured, can not inject value with id ["+valueId+"]"); } return _injectableValues.findInjectableValue(valueId, this, forProperty, beanInstance); } /** * Convenience method for accessing the default Base64 encoding * used for decoding base64 encoded binary content. * Same as calling: *<pre> * getConfig().getBase64Variant(); *</pre> */ public final Base64Variant getBase64Variant() { return _config.getBase64Variant(); } /** * Convenience method, functionally equivalent to: *<pre> * getConfig().getNodeFactory(); * </pre> */ public final JsonNodeFactory getNodeFactory() { return _config.getNodeFactory(); } /** * Method for accessing default Locale to use: convenience method for *<pre> * getConfig().getLocale(); *</pre> */ public Locale getLocale() { return _config.getLocale(); } /** * Method for accessing default TimeZone to use: convenience method for *<pre> * getConfig().getTimeZone(); *</pre> */ public TimeZone getTimeZone() { return _config.getTimeZone(); } /* /********************************************************** /* Public API, pass-through to DeserializerCache /********************************************************** */ @Deprecated // since 2.3, use overloaded variant public boolean hasValueDeserializerFor(JavaType type) { return hasValueDeserializerFor(type, null); } /** * Method for checking whether we could find a deserializer * for given type. * * @param type * @since 2.3 */ public boolean hasValueDeserializerFor(JavaType type, AtomicReference<Throwable> cause) { try { return _cache.hasValueDeserializerFor(this, _factory, type); } catch (JsonMappingException e) { if (cause != null) { cause.set(e); } } catch

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> (RuntimeException e) { if (cause == null) { // earlier behavior throw e; } cause.set(e); } return false; } /** * Method for finding a value deserializer, and creating a contextual * version if necessary, for value reached via specified property. */ @SuppressWarnings("unchecked") public final JsonDeserializer<Object> findContextualValueDeserializer(JavaType type, BeanProperty prop) throws JsonMappingException { JsonDeserializer<Object> deser = _cache.findValueDeserializer(this, _factory, type); if (deser != null) { deser = (JsonDeserializer<Object>) handleSecondaryContextualization(deser, prop, type); } return deser; } /** * Variant that will try to locate deserializer for current type, but without * performing any contextualization (unlike {@link #findContextualValueDeserializer}) * or checking for need to create a {@link TypeDeserializer} (unlike * {@link #findRootValueDeserializer(JavaType)}. * This method is usually called from within {@link ResolvableDeserializer#resolve}, * and expectation is that caller then calls either * {@link #handlePrimaryContextualization(JsonDeserializer, BeanProperty, JavaType)} or * {@link #handleSecondaryContextualization(JsonDeserializer, BeanProperty, JavaType)} at a * later point, as necessary. * * @since 2.5 */ public final JsonDeserializer<Object> findNonContextualValueDeserializer(JavaType type) throws JsonMappingException { return _cache.findValueDeserializer(this, _factory, type); } /** * Method for finding a deserializer for root-level value. */ @SuppressWarnings("unchecked") public final JsonDeserializer<Object> findRootValueDeserializer(JavaType type) throws JsonMappingException { JsonDeserializer<Object> deser = _cache.findValueDeserializer(this, _factory, type); if (deser == null) { // can this occur? return null; } deser = (JsonDeserializer<Object>) handleSecondaryContextualization(deser, null, type); TypeDeserializer typeDeser = _factory.findTypeDeserializer(_config, type); if (typeDeser != null) { //

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> important: contextualize to indicate this is for root value typeDeser = typeDeser.forProperty(null); return new TypeWrappedDeserializer(typeDeser, deser); } return deser; } /** * Convenience method, functionally same as: *<pre> * getDeserializerProvider().findKeyDeserializer(getConfig(), prop.getType(), prop); *</pre> */ public final KeyDeserializer findKeyDeserializer(JavaType keyType, BeanProperty prop) throws JsonMappingException { KeyDeserializer kd = _cache.findKeyDeserializer(this, _factory, keyType); // Second: contextualize? if (kd instanceof ContextualKeyDeserializer) { kd = ((ContextualKeyDeserializer) kd).createContextual(this, prop); } return kd; } /* /********************************************************** /* Public API, ObjectId handling /********************************************************** */ /** * Method called to find and return entry corresponding to given * Object Id: will add an entry if necessary, and never returns null */ public abstract ReadableObjectId findObjectId(Object id, ObjectIdGenerator<?> generator, ObjectIdResolver resolver); @Deprecated // since 2.4 public abstract ReadableObjectId findObjectId(Object id, ObjectIdGenerator<?> generator); /** * Method called to ensure that every object id encounter during processing * are resolved. * * @throws UnresolvedForwardReference */ public abstract void checkUnresolvedObjectId() throws UnresolvedForwardReference; /* /********************************************************** /* Public API, type handling /********************************************************** */ /** * Convenience method, functionally equivalent to: *<pre> * getConfig().constructType(cls); * </pre> */ public final JavaType constructType(Class<?> cls) { return _config.constructType(cls); } /** * Helper method to use for locating Class for given name. Should be used * instead of basic <code>Class.forName(className);</code> as it can * try using contextual class loader, or use platform-specific workarounds * (like on Android, GAE). */ public Class<?> findClass(String className) throws ClassNotFoundException { // By default, delegate to ClassUtil: can be overridden with custom handling return ClassUtil

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>.findClass(className); } /* /********************************************************** /* Public API, helper object recycling /********************************************************** */ /** * Method that can be used to get access to a reusable ObjectBuffer, * useful for efficiently constructing Object arrays and Lists. * Note that leased buffers should be returned once deserializer * is done, to allow for reuse during same round of deserialization. */ public final ObjectBuffer leaseObjectBuffer() { ObjectBuffer buf = _objectBuffer; if (buf == null) { buf = new ObjectBuffer(); } else { _objectBuffer = null; } return buf; } /** * Method to call to return object buffer previously leased with * {@link #leaseObjectBuffer}. * * @param buf Returned object buffer */ public final void returnObjectBuffer(ObjectBuffer buf) { /* Already have a reusable buffer? Let's retain bigger one * (or if equal, favor newer one, shorter life-cycle) */ if (_objectBuffer == null || buf.initialCapacity() >= _objectBuffer.initialCapacity()) { _objectBuffer = buf; } } /** * Method for accessing object useful for building arrays of * primitive types (such as int[]). */ public final ArrayBuilders getArrayBuilders() { if (_arrayBuilders == null) { _arrayBuilders = new ArrayBuilders(); } return _arrayBuilders; } /* /********************************************************** /* Extended API: handler instantiation /********************************************************** */ public abstract JsonDeserializer<Object> deserializerInstance(Annotated annotated, Object deserDef) throws JsonMappingException; public abstract KeyDeserializer keyDeserializerInstance(Annotated annotated, Object deserDef) throws JsonMappingException; /* /********************************************************** /* Extended API: resolving contextual deserializers; called /* by structured deserializers for their value/component /* deserializers /********************************************************** */ /** * Method called for primary property deserializers (ones * directly created to deserialize values of a POJO property), * to handle details of resolving * {@link ContextualDeserializer} with given property context. * * @param prop Property for which the given primary deserializer is used; never null. * * @since 2.5

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> */ public JsonDeserializer<?> handlePrimaryContextualization(JsonDeserializer<?> deser, BeanProperty prop, JavaType type) throws JsonMappingException { if (deser instanceof ContextualDeserializer) { _currentType = new LinkedNode<JavaType>(type, _currentType); try { deser = ((ContextualDeserializer) deser).createContextual(this, prop); } finally { _currentType = _currentType.next(); } } return deser; } @Deprecated // since 2.5; remove from 2.6 public JsonDeserializer<?> handlePrimaryContextualization(JsonDeserializer<?> deser, BeanProperty prop) throws JsonMappingException { return handlePrimaryContextualization(deser, prop, TypeFactory.unknownType()); } /** * Method called for secondary property deserializers (ones * NOT directly created to deal with an annotatable POJO property, * but instead created as a component -- such as value deserializers * for structured types, or deserializers for root values) * to handle details of resolving * {@link ContextualDeserializer} with given property context. * Given that these deserializers are not directly related to given property * (or, in case of root value property, to any property), annotations * accessible may or may not be relevant. * * @param prop Property for which deserializer is used, if any; null * when deserializing root values * * @since 2.5 */ public JsonDeserializer<?> handleSecondaryContextualization(JsonDeserializer<?> deser, BeanProperty prop, JavaType type) throws JsonMappingException { if (deser instanceof ContextualDeserializer) { _currentType = new LinkedNode<JavaType>(type, _currentType); try { deser = ((ContextualDeserializer) deser).createContextual(this, prop); } finally { _currentType = _currentType.next(); } } return deser; } @Deprecated // since 2.5; remove from 2.6 public JsonDeserializer<?> handleSecondaryContextualization(JsonDeserializer<?> deser, BeanProperty prop) throws JsonMappingException { if (deser instanceof ContextualDeserializer) { deser = ((ContextualDeserializer) deser).createContextual(this, prop);

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> } return deser; } /* /********************************************************** /* Parsing methods that may use reusable/-cyclable objects /********************************************************** */ /** * Convenience method for parsing a Date from given String, using * currently configured date format (accessed using * {@link DeserializationConfig#getDateFormat()}). *<p> * Implementation will handle thread-safety issues related to * date formats such that first time this method is called, * date format is cloned, and cloned instance will be retained * for use during this deserialization round. */ public Date parseDate(String dateStr) throws IllegalArgumentException { try { DateFormat df = getDateFormat(); return df.parse(dateStr); } catch (ParseException e) { throw new IllegalArgumentException("Failed to parse Date value '"+dateStr+"': "+e.getMessage()); } } /** * Convenience method for constructing Calendar instance set * to specified time, to be modified and used by caller. */ public Calendar constructCalendar(Date d) { // 08-Jan-2008, tatu: not optimal, but should work for the most part; let's revise as needed. Calendar c = Calendar.getInstance(getTimeZone()); c.setTime(d); return c; } /* /********************************************************** /* Convenience methods for reading parsed values /********************************************************** */ /** * Convenience method that may be used by composite or container deserializers, * for reading one-off values contained (for sequences, it is more efficient * to actually fetch deserializer once for the whole collection). *<p> * NOTE: when deserializing values of properties contained in composite types, * rather use {@link #readPropertyValue(JsonParser, BeanProperty, Class)}; * this method does not allow use of contextual annotations. * * @since 2.4 */ public <T> T readValue(JsonParser p, Class<T> type) throws IOException { return readValue(p, getTypeFactory().constructType(type)); } /** * @since 2.4 */ @SuppressWarnings("unchecked") public <T> T readValue(JsonParser p, JavaType type) throws IOException { JsonDeserializer<Object> deser = findRootValueDeserializer(type);

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>) instantiated * @param deser Deserializer that had the problem, if called by deserializer * (or on behalf of one) */ public void reportUnknownProperty(Object instanceOrClass, String fieldName, JsonDeserializer<?> deser) throws JsonMappingException { if (!isEnabled(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)) { return; } // Do we know properties that are expected instead? Collection<Object> propIds = (deser == null) ? null : deser.getKnownPropertyNames(); throw UnrecognizedPropertyException.from(_parser, instanceOrClass, fieldName, propIds); } /* /********************************************************** /* Methods for constructing exceptions /********************************************************** */ /** * Helper method for constructing generic mapping exception for specified type */ public JsonMappingException mappingException(Class<?> targetClass) { return mappingException(targetClass, _parser.getCurrentToken()); } public JsonMappingException mappingException(Class<?> targetClass, JsonToken token) { return JsonMappingException.from(_parser, "Can not deserialize instance of "+_calcName(targetClass)+" out of "+token+" token"); } /** * Helper method for constructing generic mapping exception with specified * message and current location information */ public JsonMappingException mappingException(String message) { return JsonMappingException.from(getParser(), message); } /** * Helper method for constructing instantiation exception for specified type, * to indicate problem with physically constructing instance of * specified class (missing constructor, exception from constructor) */ public JsonMappingException instantiationException(Class<?> instClass, Throwable t) { return JsonMappingException.from(_parser, "Can not construct instance of "+instClass.getName()+", problem: "+t.getMessage(), t); } public JsonMappingException instantiationException(Class<?> instClass, String msg) { return JsonMappingException.from(_parser, "Can not construct instance of "+instClass.getName()+", problem: "+msg); } /** * Method that will construct an exception suitable for throwing when * some String values are acceptable, but the one encountered is not. * * * @deprecated Since 2.1 should use variant that takes value */ @Deprecated public JsonMappingException weirdStringException(Class<?> instClass, String

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> msg) { return weirdStringException(null, instClass, msg); } /** * Method that will construct an exception suitable for throwing when * some String values are acceptable, but the one encountered is not. * * @param value String value from input being deserialized * @param instClass Type that String should be deserialized into * @param msg Message that describes specific problem * * @since 2.1 */ public JsonMappingException weirdStringException(String value, Class<?> instClass, String msg) { return InvalidFormatException.from(_parser, "Can not construct instance of "+instClass.getName()+" from String value '"+_valueDesc()+"': "+msg, value, instClass); } /** * Helper method for constructing exception to indicate that input JSON * Number was not suitable for deserializing into given type. */ @Deprecated public JsonMappingException weirdNumberException(Class<?> instClass, String msg) { return weirdStringException(null, instClass, msg); } /** * Helper method for constructing exception to indicate that input JSON * Number was not suitable for deserializing into given target type. */ public JsonMappingException weirdNumberException(Number value, Class<?> instClass, String msg) { return InvalidFormatException.from(_parser, "Can not construct instance of "+instClass.getName()+" from number value ("+_valueDesc()+"): "+msg, null, instClass); } /** * Helper method for constructing exception to indicate that given JSON * Object field name was not in format to be able to deserialize specified * key type. */ public JsonMappingException weirdKeyException(Class<?> keyClass, String keyValue, String msg) { return InvalidFormatException.from(_parser, "Can not construct Map key of type "+keyClass.getName()+" from String \""+_desc(keyValue)+"\": "+msg, keyValue, keyClass); } /** * Helper method for indicating that the current token was expected to be another * token. */ public JsonMappingException wrongTokenException(JsonParser p, JsonToken expToken, String msg0) { String msg = "Unexpected token ("+p.getCurrentToken()+"), expected "+expToken; if (msg0 != null) { msg = msg + ": "+msg0;

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> } return JsonMappingException.from(p, msg); } /** * Helper method for constructing exception to indicate that given * type id (parsed from JSON) could not be converted to a Java type. */ @Deprecated // since 2.5, use overloaded variant public JsonMappingException unknownTypeException(JavaType type, String id) { return JsonMappingException.from(_parser, "Could not resolve type id '"+id+"' into a subtype of "+type); } /** * @since 2.5 */ public JsonMappingException unknownTypeException(JavaType type, String id, String extraDesc) { String msg = "Could not resolve type id '"+id+"' into a subtype of "+type; if (extraDesc != null) { msg = msg + ": "+extraDesc; } return JsonMappingException.from(_parser, msg); } public JsonMappingException endOfInputException(Class<?> instClass) { return JsonMappingException.from(_parser, "Unexpected end-of-input when trying to deserialize a " +instClass.getName()); } /* /********************************************************** /* Overridable internal methods /********************************************************** */ protected DateFormat getDateFormat() { if (_dateFormat != null) { return _dateFormat; } /* 24-Feb-2012, tatu: At this point, all timezone configuration * should have occurred, with respect to default dateformat * and timezone configuration. But we still better clone * an instance as formatters may be stateful. */ DateFormat df = _config.getDateFormat(); _dateFormat = df = (DateFormat) df.clone(); return df; } protected String determineClassName(Object instance) { return ClassUtil.getClassDescription(instance); } /* /********************************************************** /* Other internal methods /********************************************************** */ protected String _calcName(Class<?> cls) { if (cls.isArray()) { return _calcName(cls.getComponentType())+"[]"; } return cls.getName(); } protected String _valueDesc() { try { return _desc(_parser.getText()); } catch (Exception e) { return "[N/A]"; } } protected

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>Override public <A extends Annotation> A getContextAnnotation(Class<A> acls) { return (_contextAnnotations == null) ? null : _contextAnnotations.get(acls); } @Override public AnnotatedMember getMember() { return _member; } // @since 2.3 -- needed so it can be overridden by unwrapping writer protected void _depositSchemaProperty(ObjectNode propertiesNode, JsonNode schemaNode) { propertiesNode.set(getName(), schemaNode); } /** * Note: will be defined in {@link BeanProperty}; as of now is not yet. *<p> * TODO: move to {@link BeanProperty} in near future, once all standard * implementations define it. * * @since 2.5 */ public boolean isVirtual() { return false; } /* /********************************************************** /* Managing and accessing of opaque internal settings /* (used by extensions) /********************************************************** */ /** * Method for accessing value of specified internal setting. * * @return Value of the setting, if any; null if none. */ public Object getInternalSetting(Object key) { return (_internalSettings == null) ? null : _internalSettings.get(key); } /** * Method for setting specific internal setting to given value * * @return Old value of the setting, if any (null if none) */ public Object setInternalSetting(Object key, Object value) { if (_internalSettings == null) { _internalSettings = new HashMap<Object,Object>(); } return _internalSettings.put(key, value); } /** * Method for removing entry for specified internal setting. * * @return Existing value of the setting, if any (null if none) */ public Object removeInternalSetting(Object key) { Object removed = null; if (_internalSettings != null) { removed = _internalSettings.remove(key); // to reduce memory usage, let's also drop the Map itself, if empty if (_internalSettings.size() == 0) { _internalSettings = null; } } return removed; } /* /********************************************************** /* Accessors /********************************************************** */ public SerializableString getSerializedName() { return _name; }

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>Property(JsonObjectFormatVisitor v) throws JsonMappingException { if (v != null) { if (isRequired()) { v.property(this); } else { v.optionalProperty(this); } } } // // // Legacy support for JsonFormatVisitable /** * Attempt to add the output of the given {@link BeanPropertyWriter} in the given {@link ObjectNode}. * Otherwise, add the default schema {@link JsonNode} in place of the writer's output * * @param propertiesNode Node which the given property would exist within * @param provider Provider that can be used for accessing dynamic aspects of serialization * processing */ @Override @Deprecated public void depositSchemaProperty(ObjectNode propertiesNode, SerializerProvider provider) throws JsonMappingException { JavaType propType = getSerializationType(); // 03-Dec-2010, tatu: SchemaAware REALLY should use JavaType, but alas it doesn't... Type hint = (propType == null) ? getGenericPropertyType() : propType.getRawClass(); JsonNode schemaNode; // Maybe it already has annotated/statically configured serializer? JsonSerializer<Object> ser = getSerializer(); if (ser == null) { // nope ser = provider.findValueSerializer(getType(), this); } boolean isOptional = !isRequired(); if (ser instanceof SchemaAware) { schemaNode = ((SchemaAware) ser).getSchema(provider, hint, isOptional) ; } else { schemaNode = com.fasterxml.jackson.databind.jsonschema.JsonSchema.getDefaultSchemaNode(); } _depositSchemaProperty(propertiesNode, schemaNode); } /* /********************************************************** /* Helper methods /********************************************************** */ protected JsonSerializer<Object> _findAndAddDynamic(PropertySerializerMap map, Class<?> type, SerializerProvider provider) throws JsonMappingException { PropertySerializerMap.SerializerAndMapResult result; if (_nonTrivialBaseType != null) { JavaType t = provider.constructSpecializedType(_nonTrivialBaseType, type); result = map.findAndAddPrimarySerializer(t, provider, this); } else { result = map.findAndAddPrimarySerializer(type, provider, this); } // did we get a

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> new map of serializers? If so, start using it if (map != result.map) { _dynamicSerializers = result.map; } return result.serializer; } /** * Method that can be used to access value of the property this * Object describes, from given bean instance. *<p> * Note: method is final as it should not need to be overridden -- rather, * calling method(s) ({@link #serializeAsField}) should be overridden * to change the behavior */ public final Object get(Object bean) throws Exception { return (_accessorMethod == null) ? _field.get(bean) : _accessorMethod.invoke(bean); } /** * Method called to handle a direct self-reference through this property. * Method can choose to indicate an error by throwing {@link JsonMappingException}; * fully handle serialization (and return true); or indicate that it should be * serialized normally (return false). *<p> * Default implementation will throw {@link JsonMappingException} if * {@link SerializationFeature#FAIL_ON_SELF_REFERENCES} is enabled; * or return <code>false</code> if it is disabled. * * @return True if method fully handled self-referential value; false if not (caller * is to handle it) or {@link JsonMappingException} if there is no way handle it */ protected boolean _handleSelfReference(Object bean, JsonGenerator gen, SerializerProvider prov, JsonSerializer<?> ser) throws JsonMappingException { if (prov.isEnabled(SerializationFeature.FAIL_ON_SELF_REFERENCES) && !ser.usesObjectId()) { // 05-Feb-2013, tatu: Usually a problem, but NOT if we are handling // object id; this may be the case for BeanSerializers at least. // 13-Feb-2014, tatu: another possible ok case: custom serializer (something // OTHER than {@link BeanSerializerBase} if (ser instanceof BeanSerializerBase) { throw new JsonMappingException("Direct self-reference leading to cycle"); } } return false; } @Override public String toString() { StringBuilder sb = new StringBuilder(40); sb.append("property

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>package com.fasterxml.jackson.databind.ser; import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.jsontype.TypeSerializer; /** * Abstract class that defines API used by {@link SerializerProvider} * to obtain actual * {@link JsonSerializer} instances from multiple distinct factories. */ public abstract class SerializerFactory { /* /********************************************************** /* Additional configuration methods /********************************************************** */ /** * Convenience method for creating a new factory instance with additional serializer * provider; equivalent to calling *<pre> * withConfig(getConfig().withAdditionalSerializers(additional)); *<pre> */ public abstract SerializerFactory withAdditionalSerializers(Serializers additional); public abstract SerializerFactory withAdditionalKeySerializers(Serializers additional); /** * Convenience method for creating a new factory instance with additional bean * serializer modifier; equivalent to calling *<pre> * withConfig(getConfig().withSerializerModifier(modifier)); *<pre> */ public abstract SerializerFactory withSerializerModifier(BeanSerializerModifier modifier); /* /********************************************************** /* Basic SerializerFactory API: /********************************************************** */ /** * Method called to create (or, for immutable serializers, reuse) a serializer for given type. * * @param prov Provider that needs to be used to resolve annotation-provided * serializers (but NOT for others) * * @since 2.1 (earlier versions had method with different signature) */ public abstract JsonSerializer<Object> createSerializer(SerializerProvider prov, JavaType baseType) throws JsonMappingException; /** * Method called to create a type information serializer for given base type, * if one is needed. If not needed (no polymorphic handling configured), should * return null. * * @param baseType Declared type to use as the base type for type information serializer * * @return Type serializer to use for the base type, if one is needed; null if not. */ public abstract TypeSerializer createTypeSerializer(SerializationConfig config, JavaType baseType) throws JsonMappingException; /** * Method called to create serializer to use for serializing JSON property names (which must * be output as <code>JsonToken.FIELD_NAME</code>) for Map

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> that has specified declared * key type, and is for specified property (or, if property is null, as root value) * * @param baseType Declared type for Map keys * @param defaultImpl Default key serializer implementation to use, if no custom ones * are found (may be null) * * @return Serializer to use, if factory knows it; null if not (in which case default * serializer is to be used) */ public abstract JsonSerializer<Object> createKeySerializer(SerializationConfig config, JavaType baseType, JsonSerializer<Object> defaultImpl) throws JsonMappingException; }

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> serializer definitions"); } return new BeanSerializerFactory(config); } @Override protected Iterable<Serializers> customSerializers() { return _factoryConfig.serializers(); } /* /********************************************************** /* SerializerFactory impl /********************************************************** */ /** * Main serializer constructor method. We will have to be careful * with respect to ordering of various method calls: essentially * we want to reliably figure out which classes are standard types, * and which are beans. The problem is that some bean Classes may * implement standard interfaces (say, {@link java.lang.Iterable}. *<p> * Note: sub-classes may choose to complete replace implementation, * if they want to alter priority of serializer lookups. */ @Override @SuppressWarnings("unchecked") public JsonSerializer<Object> createSerializer(SerializerProvider prov, JavaType origType) throws JsonMappingException { // Very first thing, let's check if there is explicit serializer annotation: final SerializationConfig config = prov.getConfig(); BeanDescription beanDesc = config.introspect(origType); JsonSerializer<?> ser = findSerializerFromAnnotation(prov, beanDesc.getClassInfo()); if (ser != null) { return (JsonSerializer<Object>) ser; } boolean staticTyping; // Next: we may have annotations that further define types to use... JavaType type = modifyTypeByAnnotation(config, beanDesc.getClassInfo(), origType); if (type == origType) { // no changes, won't force static typing staticTyping = false; } else { // changes; assume static typing; plus, need to re-introspect if class differs staticTyping = true; if (!type.hasRawClass(origType.getRawClass())) { beanDesc = config.introspect(type); } } // Slight detour: do we have a Converter to consider? Converter<Object,Object> conv = beanDesc.findSerializationConverter(); if (conv == null) { // no, simple return (JsonSerializer<Object>) _createSerializer2(prov, type, beanDesc, staticTyping); } JavaType delegateType = conv.getOutputType(prov.getTypeFactory()); // One more twist, as per [Issue#288]; probably need to get new Bean

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>Desc if (!delegateType.hasRawClass(type.getRawClass())) { beanDesc = config.introspect(delegateType); // [#359]: explicitly check (again) for @JsonSerializer... ser = findSerializerFromAnnotation(prov, beanDesc.getClassInfo()); } if (ser == null) { ser = _createSerializer2(prov, delegateType, beanDesc, true); } return new StdDelegatingSerializer(conv, delegateType, ser); } protected JsonSerializer<?> _createSerializer2(SerializerProvider prov, JavaType type, BeanDescription beanDesc, boolean staticTyping) throws JsonMappingException { // Then JsonSerializable, @JsonValue etc: JsonSerializer<?> ser = findSerializerByAnnotations(prov, type, beanDesc); if (ser != null) { return ser; } final SerializationConfig config = prov.getConfig(); // Container types differ from non-container types // (note: called method checks for module-provided serializers) if (type.isContainerType()) { if (!staticTyping) { staticTyping = usesStaticTyping(config, beanDesc, null); // [Issue#23]: Need to figure out how to force passed parameterization // to stick... /* if (property == null) { JavaType t = origType.getContentType(); if (t != null && !t.hasRawClass(Object.class)) { staticTyping = true; } } */ } // 03-Aug-2012, tatu: As per [Issue#40], may require POJO serializer... ser = buildContainerSerializer(prov, type, beanDesc, staticTyping); // Will return right away, since called method does post-processing: if (ser != null) { return ser; } } else { // Modules may provide serializers of POJO types: for (Serializers serializers : customSerializers()) { ser = serializers.findSerializer(config, type, beanDesc); if (ser != null) { break; } } } // Otherwise, we will check "primary types"; both marker types that // indicate specific handling (JsonSerializable), or main types that have // precedence over container types if (ser == null) { ser =

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> findSerializerByLookup(type, config, beanDesc, staticTyping); if (ser == null) { ser = findSerializerByPrimaryType(prov, type, beanDesc, staticTyping); if (ser == null) { // And this is where this class comes in: if type is not a // known "primary JDK type", perhaps it's a bean? We can still // get a null, if we can't find a single suitable bean property. ser = findBeanSerializer(prov, type, beanDesc); // Finally: maybe we can still deal with it as an implementation of some basic JDK interface? if (ser == null) { ser = findSerializerByAddonType(config, type, beanDesc, staticTyping); // 18-Sep-2014, tatu: Actually, as per [jackson-databind#539], need to get // 'unknown' serializer assigned earlier, here, so that it gets properly // post-processed if (ser == null) { ser = prov.getUnknownTypeSerializer(beanDesc.getBeanClass()); } } } } } if (ser != null) { // [Issue#120]: Allow post-processing if (_factoryConfig.hasSerializerModifiers()) { for (BeanSerializerModifier mod : _factoryConfig.serializerModifiers()) { ser = mod.modifySerializer(config, beanDesc, ser); } } } return ser; } /* /********************************************************** /* Other public methods that are not part of /* JsonSerializerFactory API /********************************************************** */ /** * Method that will try to construct a {@link BeanSerializer} for * given class. Returns null if no properties are found. */ public JsonSerializer<Object> findBeanSerializer(SerializerProvider prov, JavaType type, BeanDescription beanDesc) throws JsonMappingException { // First things first: we know some types are not beans... if (!isPotentialBeanType(type.getRawClass())) { // 03-Aug-2012, tatu: Except we do need to allow serializers for Enums, // as per [Issue#24] if (!type.isEnumType()) { return null; } } return constructBeanSerializer(prov, beanDesc);

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> } /** * Method called to create a type information serializer for values of given * non-container property * if one is needed. If not needed (no polymorphic handling configured), should * return null. * * @param baseType Declared type to use as the base type for type information serializer * * @return Type serializer to use for property values, if one is needed; null if not. */ public TypeSerializer findPropertyTypeSerializer(JavaType baseType, SerializationConfig config, AnnotatedMember accessor) throws JsonMappingException { AnnotationIntrospector ai = config.getAnnotationIntrospector(); TypeResolverBuilder<?> b = ai.findPropertyTypeResolver(config, accessor, baseType); // Defaulting: if no annotations on member, check value class if (b == null) { return createTypeSerializer(config, baseType); } Collection<NamedType> subtypes = config.getSubtypeResolver().collectAndResolveSubtypes( accessor, config, ai, baseType); return b.buildTypeSerializer(config, baseType, subtypes); } /** * Method called to create a type information serializer for values of given * container property * if one is needed. If not needed (no polymorphic handling configured), should * return null. * * @param containerType Declared type of the container to use as the base type for type information serializer * * @return Type serializer to use for property value contents, if one is needed; null if not. */ public TypeSerializer findPropertyContentTypeSerializer(JavaType containerType, SerializationConfig config, AnnotatedMember accessor) throws JsonMappingException { JavaType contentType = containerType.getContentType(); AnnotationIntrospector ai = config.getAnnotationIntrospector(); TypeResolverBuilder<?> b = ai.findPropertyContentTypeResolver(config, accessor, containerType); // Defaulting: if no annotations on member, check value class if (b == null) { return createTypeSerializer(config, contentType); } Collection<NamedType> subtypes = config.getSubtypeResolver().collectAndResolveSubtypes(accessor, config, ai, contentType); return b.buildTypeSerializer(config, contentType, subtypes); } /* /********************************************************** /* Overridable non-public factory methods

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> /********************************************************** */ /** * Method called to construct serializer for serializing specified bean type. * * @since 2.1 */ @SuppressWarnings("unchecked") protected JsonSerializer<Object> constructBeanSerializer(SerializerProvider prov, BeanDescription beanDesc) throws JsonMappingException { // 13-Oct-2010, tatu: quick sanity check: never try to create bean serializer for plain Object // 05-Jul-2012, tatu: ... but we should be able to just return "unknown type" serializer, right? if (beanDesc.getBeanClass() == Object.class) { return prov.getUnknownTypeSerializer(Object.class); // throw new IllegalArgumentException("Can not create bean serializer for Object.class"); } final SerializationConfig config = prov.getConfig(); BeanSerializerBuilder builder = constructBeanSerializerBuilder(beanDesc); builder.setConfig(config); // First: any detectable (auto-detect, annotations) properties to serialize? List<BeanPropertyWriter> props = findBeanProperties(prov, beanDesc, builder); if (props == null) { props = new ArrayList<BeanPropertyWriter>(); } // [databind#638]: Allow injection of "virtual" properties: prov.getAnnotationIntrospector().findAndAddVirtualProperties(config, beanDesc.getClassInfo(), props); // [JACKSON-440] Need to allow modification bean properties to serialize: if (_factoryConfig.hasSerializerModifiers()) { for (BeanSerializerModifier mod : _factoryConfig.serializerModifiers()) { props = mod.changeProperties(config, beanDesc, props); } } // Any properties to suppress? props = filterBeanProperties(config, beanDesc, props); // [JACKSON-440] Need to allow reordering of properties to serialize if (_factoryConfig.hasSerializerModifiers()) { for (BeanSerializerModifier mod : _factoryConfig.serializerModifiers()) { props = mod.orderProperties(config, beanDesc, props); } } /* And if Object Id is needed, some preparation for that as well: better * do before view handling, mostly for the custom id case which needs * access to a property */ builder.setObjectIdWriter(constructObjectIdHandler

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> if (beanDesc.hasKnownClassAnnotations()) { return builder.createDummy(); } } return ser; } protected ObjectIdWriter constructObjectIdHandler(SerializerProvider prov, BeanDescription beanDesc, List<BeanPropertyWriter> props) throws JsonMappingException { ObjectIdInfo objectIdInfo = beanDesc.getObjectIdInfo(); if (objectIdInfo == null) { return null; } ObjectIdGenerator<?> gen; Class<?> implClass = objectIdInfo.getGeneratorType(); // Just one special case: Property-based generator is trickier if (implClass == ObjectIdGenerators.PropertyGenerator.class) { // most special one, needs extra work String propName = objectIdInfo.getPropertyName().getSimpleName(); BeanPropertyWriter idProp = null; for (int i = 0, len = props.size() ;; ++i) { if (i == len) { throw new IllegalArgumentException("Invalid Object Id definition for "+beanDesc.getBeanClass().getName() +": can not find property with name '"+propName+"'"); } BeanPropertyWriter prop = props.get(i); if (propName.equals(prop.getName())) { idProp = prop; /* Let's force it to be the first property to output * (although it may still get rearranged etc) */ if (i > 0) { props.remove(i); props.add(0, idProp); } break; } } JavaType idType = idProp.getType(); gen = new PropertyBasedObjectIdGenerator(objectIdInfo, idProp); // one more thing: must ensure that ObjectIdWriter does not actually write the value: return ObjectIdWriter.construct(idType, (PropertyName) null, gen, objectIdInfo.getAlwaysAsId()); } // other types are simpler JavaType type = prov.constructType(implClass); // Could require type to be passed explicitly, but we should be able to find it too: JavaType idType = prov.getTypeFactory().findTypeParameters(type, ObjectIdGenerator.class)[0]; gen = prov.objectIdGeneratorInstance(beanDesc.getClassInfo(), objectIdInfo); return ObjectIdWriter.construct(idType, objectIdInfo.getPropertyName(), gen, objectIdInfo.get

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>AlwaysAsId()); } /** * Method called to construct a filtered writer, for given view * definitions. Default implementation constructs filter that checks * active view type to views property is to be included in. */ protected BeanPropertyWriter constructFilteredBeanWriter(BeanPropertyWriter writer, Class<?>[] inViews) { return FilteredBeanPropertyWriter.constructViewBased(writer, inViews); } protected PropertyBuilder constructPropertyBuilder(SerializationConfig config, BeanDescription beanDesc) { return new PropertyBuilder(config, beanDesc); } protected BeanSerializerBuilder constructBeanSerializerBuilder(BeanDescription beanDesc) { return new BeanSerializerBuilder(beanDesc); } /* /********************************************************** /* Overridable non-public introspection methods /********************************************************** */ /** * Helper method used to skip processing for types that we know * can not be (i.e. are never consider to be) beans: * things like primitives, Arrays, Enums, and proxy types. *<p> * Note that usually we shouldn't really be getting these sort of * types anyway; but better safe than sorry. */ protected boolean isPotentialBeanType(Class<?> type) { return (ClassUtil.canBeABeanType(type) == null) && !ClassUtil.isProxyType(type); } /** * Method used to collect all actual serializable properties. * Can be overridden to implement custom detection schemes. */ protected List<BeanPropertyWriter> findBeanProperties(SerializerProvider prov, BeanDescription beanDesc, BeanSerializerBuilder builder) throws JsonMappingException { List<BeanPropertyDefinition> properties = beanDesc.findProperties(); final SerializationConfig config = prov.getConfig(); // [JACKSON-429]: ignore specified types removeIgnorableTypes(config, beanDesc, properties); // and possibly remove ones without matching mutator... if (config.isEnabled(MapperFeature.REQUIRE_SETTERS_FOR_GETTERS)) { removeSetterlessGetters(config, beanDesc, properties); } // nothing? can't proceed (caller may or may not throw an exception) if (properties.isEmpty()) { return null; } // null is for value type serializer, which we don't have access to

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>(); while (it.hasNext()) { BeanPropertyDefinition property = it.next(); AnnotatedMember accessor = property.getAccessor(); if (accessor == null) { it.remove(); continue; } Class<?> type = accessor.getRawType(); Boolean result = ignores.get(type); if (result == null) { BeanDescription desc = config.introspectClassAnnotations(type); AnnotatedClass ac = desc.getClassInfo(); result = intr.isIgnorableType(ac); // default to false, non-ignorable if (result == null) { result = Boolean.FALSE; } ignores.put(type, result); } // lotsa work, and yes, it is ignorable type, so: if (result.booleanValue()) { it.remove(); } } } /** * Helper method that will remove all properties that do not have a mutator. */ protected void removeSetterlessGetters(SerializationConfig config, BeanDescription beanDesc, List<BeanPropertyDefinition> properties) { Iterator<BeanPropertyDefinition> it = properties.iterator(); while (it.hasNext()) { BeanPropertyDefinition property = it.next(); // one caveat: as per [JACKSON-806], only remove implicit properties; // explicitly annotated ones should remain if (!property.couldDeserialize() && !property.isExplicitlyIncluded()) { it.remove(); } } } /* /********************************************************** /* Internal helper methods /********************************************************** */ /** * Secondary helper method for constructing {@link BeanPropertyWriter} for * given member (field or method). */ protected BeanPropertyWriter _constructWriter(SerializerProvider prov, BeanPropertyDefinition propDef, TypeBindings typeContext, PropertyBuilder pb, boolean staticTyping, AnnotatedMember accessor) throws JsonMappingException { final PropertyName name = propDef.getFullName(); if (prov.canOverrideAccessModifiers()) { accessor.fixAccess(); } JavaType type = accessor.getType(typeContext); BeanProperty.Std property = new BeanProperty.Std(name, type, propDef.getWrapperName(), pb.getClassAnnotations(), accessor, propDef.getMetadata()); // Does member specify a serializer? If so, let

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>package com.fasterxml.jackson.databind.ser.std; import java.io.*; import java.lang.reflect.Type; import java.util.*; import java.util.concurrent.atomic.*; import com.fasterxml.jackson.core.*; import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitorWrapper; import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonIntegerFormatVisitor; import com.fasterxml.jackson.databind.ser.BasicSerializerFactory; /** * Class that providers access to serializers user for non-structured JDK types that * are serializer as scalars; some using basic {@link ToStringSerializer}, * others explicit serializers. */ @SuppressWarnings("serial") public class StdJdkSerializers { /** * Method called by {@link BasicSerializerFactory} to access * all serializers this class provides. */ public static Collection<Map.Entry<Class<?>, Object>> all() { HashMap<Class<?>,Object> sers = new HashMap<Class<?>,Object>(); // First things that 'toString()' can handle final ToStringSerializer sls = ToStringSerializer.instance; sers.put(java.net.URL.class, sls); sers.put(java.net.URI.class, sls); sers.put(Currency.class, sls); sers.put(UUID.class, new UUIDSerializer()); sers.put(java.util.regex.Pattern.class, sls); sers.put(Locale.class, sls); // starting with 1.7, use compact String for Locale sers.put(Locale.class, sls); // then atomic types sers.put(AtomicReference.class, AtomicReferenceSerializer.class); sers.put(AtomicBoolean.class, AtomicBooleanSerializer.class); sers.put(AtomicInteger.class, AtomicIntegerSerializer.class); sers.put(AtomicLong.class, AtomicLongSerializer.class); // then other types that need specialized serializers sers.put(File.class, FileSerializer.class); sers.put(Class.class, ClassSerializer.class); // And then some stranger types... not 100%

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> they are needed but: sers.put(Void.class, NullSerializer.instance); sers.put(Void.TYPE, NullSerializer.instance); return sers.entrySet(); } /* /********************************************************** /* Serializers for atomic types /********************************************************** */ public static class AtomicBooleanSerializer extends StdScalarSerializer<AtomicBoolean> { public AtomicBooleanSerializer() { super(AtomicBoolean.class, false); } @Override public void serialize(AtomicBoolean value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonGenerationException { jgen.writeBoolean(value.get()); } @Override public JsonNode getSchema(SerializerProvider provider, Type typeHint) { return createSchemaNode("boolean", true); } @Override public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) throws JsonMappingException { visitor.expectBooleanFormat(typeHint); } } public static class AtomicIntegerSerializer extends StdScalarSerializer<AtomicInteger> { public AtomicIntegerSerializer() { super(AtomicInteger.class, false); } @Override public void serialize(AtomicInteger value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonGenerationException { jgen.writeNumber(value.get()); } @Override public JsonNode getSchema(SerializerProvider provider, Type typeHint) { return createSchemaNode("integer", true); } @Override public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) throws JsonMappingException { JsonIntegerFormatVisitor v2 = visitor.expectIntegerFormat(typeHint); if (v2 != null) { v2.numberType(JsonParser.NumberType.INT); } } } public static class AtomicLongSerializer extends StdScalarSerializer<AtomicLong> { public AtomicLongSerializer() { super(AtomicLong.class, false); } @Override public void serialize(AtomicLong value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonGenerationException { jgen.writeNumber(value.get()); } @Override public JsonNode getSchema(SerializerProvider provider, Type typeHint) { return createSchemaNode("integer", true); } @Override public void acceptJsonFormatVisitor(JsonFormatVisitor

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>Wrapper visitor, JavaType typeHint) throws JsonMappingException { JsonIntegerFormatVisitor v2 = visitor.expectIntegerFormat(typeHint); if (v2 != null) { v2.numberType(JsonParser.NumberType.LONG); } } } public static class AtomicReferenceSerializer extends StdSerializer<AtomicReference<?>> { public AtomicReferenceSerializer() { super(AtomicReference.class, false); } @Override public void serialize(AtomicReference<?> value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonGenerationException { provider.defaultSerializeValue(value.get(), jgen); } @Override public JsonNode getSchema(SerializerProvider provider, Type typeHint) { return createSchemaNode("any", true); } @Override public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) throws JsonMappingException { visitor.expectAnyFormat(typeHint); } } }

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>tability of the field. */ if (fields == null) { fields = new LinkedHashMap<String,AnnotatedField>(); } fields.put(f.getName(), _constructField(f)); } // And then... any mix-in overrides? if (_mixInResolver != null) { Class<?> mixin = _mixInResolver.findMixInClassFor(c); if (mixin != null) { _addFieldMixIns(parent, mixin, fields); } } } return fields; } /** * Method called to add field mix-ins from given mix-in class (and its fields) * into already collected actual fields (from introspected classes and their * super-classes) */ protected void _addFieldMixIns(Class<?> targetClass, Class<?> mixInCls, Map<String,AnnotatedField> fields) { List<Class<?>> parents = new ArrayList<Class<?>>(); parents.add(mixInCls); ClassUtil.findSuperTypes(mixInCls, targetClass, parents); for (Class<?> mixin : parents) { for (Field mixinField : mixin.getDeclaredFields()) { // there are some dummy things (static, synthetic); better ignore if (!_isIncludableField(mixinField)) { continue; } String name = mixinField.getName(); // anything to mask? (if not, quietly ignore) AnnotatedField maskedField = fields.get(name); if (maskedField != null) { _addOrOverrideAnnotations(maskedField, mixinField.getDeclaredAnnotations()); } } } } /* /********************************************************** /* Helper methods, constructing value types /********************************************************** */ protected AnnotatedMethod _constructMethod(Method m) { /* note: parameter annotations not used for regular (getter, setter) * methods; only for creator methods (static factory methods) * -- at least not yet! */ if (_annotationIntrospector == null) { // when annotation processing is disabled return new AnnotatedMethod(this, m, _emptyAnnotationMap(), null); } return new AnnotatedMethod(this, m, _collectRelevantAnnotations(m.getDeclaredAnnotations()), null); } protected AnnotatedConstructor _constructConstructor(Constructor<?> ctor, boolean defaultCtor)

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> no explicit name -- problem! // [Issue#541] ... but only as long as it's visible if (!node.isVisible) { continue; } throw new IllegalStateException("Conflicting/ambiguous property name definitions (implicit name '" +_name+"'): found multiple explicit names: " +newNames+", but also implicit accessor: "+node); } POJOPropertyBuilder prop = props.get(name); if (prop == null) { prop = new POJOPropertyBuilder(_internalName, name, _annotationIntrospector, _forSerialization); props.put(name, prop); } // ultra-clumsy, part 2 -- lambdas would be nice here if (firstAcc == _fields) { Linked<AnnotatedField> n2 = (Linked<AnnotatedField>) node; prop._fields = n2.withNext(prop._fields); } else if (firstAcc == _getters) { Linked<AnnotatedMethod> n2 = (Linked<AnnotatedMethod>) node; prop._getters = n2.withNext(prop._getters); } else if (firstAcc == _setters) { Linked<AnnotatedMethod> n2 = (Linked<AnnotatedMethod>) node; prop._setters = n2.withNext(prop._setters); } else if (firstAcc == _ctorParameters) { Linked<AnnotatedParameter> n2 = (Linked<AnnotatedParameter>) node; prop._ctorParameters = n2.withNext(prop._ctorParameters); } else { throw new IllegalStateException("Internal error: mismatched accessors, property: "+this); } } } private Set<PropertyName> _findExplicitNames(Linked<? extends AnnotatedMember> node, Set<PropertyName> renamed) { for (; node != null; node = node.next) { /* 30-Mar-2014, tatu: Second check should not be needed, but seems like * removing it can cause nasty exceptions with certain version * combinations (2.4 databind, an older module). * So leaving it in for now until this is resolved * (or version beyond 2.4) */ if (!node.isNameExplicit || node.name == null) { continue;

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> return bean; } if (i == propCount) { break; } SettableBeanProperty prop = props[i]; ++i; if (prop != null) { // normal case if (activeView == null || prop.visibleInView(activeView)) { try { prop.deserializeAndSet(p, ctxt, bean); } catch (Exception e) { wrapAndThrow(e, bean, prop.getName(), ctxt); } continue; } } // otherwise, skip it (view-filtered, no prop etc) p.skipChildren(); } // Ok; extra fields? Let's fail, unless ignoring extra props is fine if (!_ignoreAllUnknown) { throw ctxt.mappingException("Unexpected JSON values; expected at most "+propCount+" properties (in JSON Array)"); } // otherwise, skip until end while (p.nextToken() != JsonToken.END_ARRAY) { p.skipChildren(); } return bean; } protected Object _deserializeWithCreator(JsonParser p, DeserializationContext ctxt) throws IOException { if (_delegateDeserializer != null) { return _valueInstantiator.createUsingDelegate(ctxt, _delegateDeserializer.deserialize(p, ctxt)); } if (_propertyBasedCreator != null) { return _deserializeUsingPropertyBased(p, ctxt); } // should only occur for abstract types... if (_beanType.isAbstract()) { throw JsonMappingException.from(p, "Can not instantiate abstract type "+_beanType +" (need to add/enable type information?)"); } throw JsonMappingException.from(p, "No suitable constructor found for type " +_beanType+": can not instantiate from JSON object (need to add/enable type information?)"); } /** * Method called to deserialize bean using "property-based creator": * this means that a non-default constructor or factory method is * called, and then possibly other setters. The trick is that * values for creator method need to be buffered, first; and * due to non-guaranteed ordering possibly some other properties * as well. */ @Override protected final Object _deserializeUsingPropertyBased(final JsonParser p, final DeserializationContext ctxt) throws IOException { final Property

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>package com.fasterxml.jackson.databind.ser.std; import java.io.IOException; import java.lang.reflect.Type; import java.text.DateFormat; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.annotation.JacksonStdImpl; import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitorWrapper; /** * Compared to regular {@link java.util.Date} serialization, we do use String * representation here. Why? Basically to truncate of time part, since * that should not be used by plain SQL date. */ @JacksonStdImpl @SuppressWarnings("serial") public class SqlDateSerializer extends DateTimeSerializerBase<java.sql.Date> { public SqlDateSerializer() { /* 12-Apr-2014, tatu: for now, pass explicit 'false' to mean 'not using timestamp', * for backwards compatibility; this differs from other Date/Calendar types. */ this(Boolean.FALSE); } protected SqlDateSerializer(Boolean useTimestamp) { super(java.sql.Date.class, useTimestamp, null); } @Override public SqlDateSerializer withFormat(Boolean timestamp, DateFormat customFormat) { return new SqlDateSerializer(timestamp); } @Override protected long _timestamp(java.sql.Date value) { return (value == null) ? 0L : value.getTime(); } @Override public void serialize(java.sql.Date value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonGenerationException { if (_useTimestamp) { jgen.writeNumber(_timestamp(value)); } else { jgen.writeString(value.toString()); } } @Override public JsonNode getSchema(SerializerProvider provider, Type typeHint) { //todo: (ryan) add a format for the date in the schema? return createSchemaNode("string", true); } @Override public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) throws JsonMappingException { _acceptJson

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> } int i = 0; try { for (final int len = props.length; i < len; ++i) { BeanPropertyWriter prop = props[i]; if (prop == null) { // can have nulls in filtered list; but if so, MUST write placeholders gen.writeNull(); } else { prop.serializeAsElement(bean, gen, provider); } } // NOTE: any getters can not be supported either //if (_anyGetterWriter != null) { // _anyGetterWriter.getAndSerialize(bean, gen, provider); //} } catch (Exception e) { String name = (i == props.length) ? "[anySetter]" : props[i].getName(); wrapAndThrow(provider, e, bean, name); } catch (StackOverflowError e) { JsonMappingException mapE = new JsonMappingException("Infinite recursion (StackOverflowError)", e); String name = (i == props.length) ? "[anySetter]" : props[i].getName(); mapE.prependPath(new JsonMappingException.Reference(bean, name)); throw mapE; } } /* /********************************************************** /* Standard methods /********************************************************** */ @Override public String toString() { return "BeanAsArraySerializer for "+handledType().getName(); } }

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>package com.fasterxml.jackson.databind.ser.std; import java.io.IOException; import java.lang.reflect.Type; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.databind.JavaType; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitorWrapper; /** * Also: default bean access will not do much good with Class.class. But * we can just serialize the class name and that should be enough. */ @SuppressWarnings("serial") public class ClassSerializer extends StdScalarSerializer<Class<?>> { public ClassSerializer() { super(Class.class, false); } @Override public void serialize(Class<?> value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonGenerationException { jgen.writeString(value.getName()); } @Override public JsonNode getSchema(SerializerProvider provider, Type typeHint) { return createSchemaNode("string", true); } @Override public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) throws JsonMappingException { visitor.expectStringFormat(typeHint); } }

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> @JacksonStdImpl final static class EnumKD extends StdKeyDeserializer { private static final long serialVersionUID = 1L; protected final EnumResolver<?> _resolver; protected final AnnotatedMethod _factory; protected EnumKD(EnumResolver<?> er, AnnotatedMethod factory) { super(-1, er.getEnumClass()); _resolver = er; _factory = factory; } @Override public Object _parse(String key, DeserializationContext ctxt) throws JsonMappingException { if (_factory != null) { try { return _factory.call1(key); } catch (Exception e) { ClassUtil.unwrapAndThrowAsIAE(e); } } Enum<?> e = _resolver.findEnum(key); if (e == null && !ctxt.getConfig().isEnabled(DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_AS_NULL)) { throw ctxt.weirdKeyException(_keyClass, key, "not one of values for Enum class"); } return e; } } /** * Key deserializer that calls a single-string-arg constructor * to instantiate desired key type. */ final static class StringCtorKeyDeserializer extends StdKeyDeserializer { private static final long serialVersionUID = 1L; protected final Constructor<?> _ctor; public StringCtorKeyDeserializer(Constructor<?> ctor) { super(-1, ctor.getDeclaringClass()); _ctor = ctor; } @Override public Object _parse(String key, DeserializationContext ctxt) throws Exception { return _ctor.newInstance(key); } } /** * Key deserializer that calls a static no-args factory method * to instantiate desired key type. */ final static class StringFactoryKeyDeserializer extends StdKeyDeserializer { private static final long serialVersionUID = 1L; final Method _factoryMethod; public StringFactoryKeyDeserializer(Method fm) { super(-1, fm.getDeclaringClass()); _factoryMethod = fm; } @Override public Object _parse(String key, DeserializationContext ctxt) throws Exception { return _factoryMethod.invoke(null, key); } } }

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>" IOExceptions to be passed as is if (t instanceof Error) { throw (Error) t; } // ... except for mapping exceptions if (t instanceof IOException && !(t instanceof JsonMappingException)) { throw (IOException) t; } throw JsonMappingException.wrapWithPath(t, ref, key); } }

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>package com.fasterxml.jackson.databind; import java.io.IOException; import java.io.Serializable; import java.util.*; import com.fasterxml.jackson.core.*; /** * Checked exception used to signal fatal problems with mapping of * content. *<p> * One additional feature is the ability to denote relevant path * of references (during serialization/deserialization) to help in * troubleshooting. */ public class JsonMappingException extends JsonProcessingException { private static final long serialVersionUID = 1L; /** * Let's limit length of reference chain, to limit damage in cases * of infinite recursion. */ final static int MAX_REFS_TO_LIST = 1000; /* /********************************************************** /* Helper classes /********************************************************** */ /** * Simple bean class used to contain references. References * can be added to indicate execution/reference path that * lead to the problem that caused this exception to be * thrown. */ public static class Reference implements Serializable { private static final long serialVersionUID = 1L; /** * Object through which reference was resolved. Can be either * actual instance (usually the case for serialization), or * Class (usually the case for deserialization). */ protected Object _from; /** * Name of field (for beans) or key (for Maps) that is part * of the reference. May be null for Collection types (which * generally have {@link #_index} defined), or when resolving * Map classes without (yet) having an instance to operate on. */ protected String _fieldName; /** * Index within a {@link Collection} instance that contained * the reference; used if index is relevant and available. * If either not applicable, or not available, -1 is used to * denote "not known". */ protected int _index = -1; /** * Default constructor for deserialization/sub-classing purposes */ protected Reference() { } public Reference(Object from) { _from = from; } public Reference(Object from, String fieldName) { _from = from; if (fieldName == null) { throw new NullPointerException("Can not pass null fieldName"); } _fieldName = fieldName; }

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> public Reference(Object from, int index) { _from = from; _index = index; } public void setFrom(Object o) { _from = o; } public void setFieldName(String n) { _fieldName = n; } public void setIndex(int ix) { _index = ix; } public Object getFrom() { return _from; } public String getFieldName() { return _fieldName; } public int getIndex() { return _index; } @Override public String toString() { StringBuilder sb = new StringBuilder(); Class<?> cls = (_from instanceof Class<?>) ? ((Class<?>)_from) : _from.getClass(); /* Hmmh. Although Class.getName() is mostly ok, it does look * butt-ugly for arrays. So let's use getSimpleName() instead; * but have to prepend package name too. */ Package pkg = cls.getPackage(); if (pkg != null) { sb.append(pkg.getName()); sb.append('.'); } sb.append(cls.getSimpleName()); sb.append('['); if (_fieldName != null) { sb.append('"'); sb.append(_fieldName); sb.append('"'); } else if (_index >= 0) { sb.append(_index); } else { sb.append('?'); } sb.append(']'); return sb.toString(); } } /* /********************************************************** /* State/configuration /********************************************************** */ /** * Path through which problem that triggering throwing of * this exception was reached. */ protected LinkedList<Reference> _path; /* /********************************************************** /* Life-cycle /********************************************************** */ public JsonMappingException(String msg) { super(msg); } public JsonMappingException(String msg, Throwable rootCause) { super(msg, rootCause); } public JsonMappingException(String msg, JsonLocation loc) { super(msg, loc); } public JsonMappingException(String msg, JsonLocation loc, Throwable rootCause) { super(msg, loc, rootCause); } public static JsonMappingException from(JsonParser jp, String msg) { return new JsonMappingException(msg, ((jp == null) ? null : jp.getTokenLocation()));

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> } public static JsonMappingException from(JsonParser jp, String msg, Throwable problem) { return new JsonMappingException(msg, ((jp == null) ? null : jp.getTokenLocation()), problem); } /** * Factory method used when "upgrading" an {@link IOException} into * {@link JsonMappingException}: usually only needed to comply with * a signature. * * @since 2.1 */ public static JsonMappingException fromUnexpectedIOE(IOException src) { return new JsonMappingException("Unexpected IOException (of type " +src.getClass().getName()+"): "+src.getMessage(), (JsonLocation)null, src); } /** * Method that can be called to either create a new JsonMappingException * (if underlying exception is not a JsonMappingException), or augment * given exception with given path/reference information. * * This version of method is called when the reference is through a * non-indexed object, such as a Map or POJO/bean. */ public static JsonMappingException wrapWithPath(Throwable src, Object refFrom, String refFieldName) { return wrapWithPath(src, new Reference(refFrom, refFieldName)); } /** * Method that can be called to either create a new JsonMappingException * (if underlying exception is not a JsonMappingException), or augment * given exception with given path/reference information. * * This version of method is called when the reference is through an * index, which happens with arrays and Collections. */ public static JsonMappingException wrapWithPath(Throwable src, Object refFrom, int index) { return wrapWithPath(src, new Reference(refFrom, index)); } /** * Method that can be called to either create a new JsonMappingException * (if underlying exception is not a JsonMappingException), or augment * given exception with given path/reference information. */ public static JsonMappingException wrapWithPath(Throwable src, Reference ref) { JsonMappingException jme; if (src instanceof JsonMappingException) { jme = (JsonMappingException) src; } else { String msg = src.getMessage(); /* Related to [JACKSON-62], let's use a more meaningful placeholder * if all we have is

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> null */ if (msg == null || msg.length() == 0) { msg = "(was "+src.getClass().getName()+")"; } jme = new JsonMappingException(msg, null, src); } jme.prependPath(ref); return jme; } /* /********************************************************** /* Accessors/mutators /********************************************************** */ /** * Method for accessing full structural path within type hierarchy * down to problematic property. */ public List<Reference> getPath() { if (_path == null) { return Collections.emptyList(); } return Collections.unmodifiableList(_path); } /** * Method for accesing description of path that lead to the * problem that triggered this exception */ public String getPathReference() { return getPathReference(new StringBuilder()).toString(); } public StringBuilder getPathReference(StringBuilder sb) { _appendPathDesc(sb); return sb; } /** * Method called to prepend a reference information in front of * current path */ public void prependPath(Object referrer, String fieldName) { Reference ref = new Reference(referrer, fieldName); prependPath(ref); } /** * Method called to prepend a reference information in front of * current path */ public void prependPath(Object referrer, int index) { Reference ref = new Reference(referrer, index); prependPath(ref); } public void prependPath(Reference r) { if (_path == null) { _path = new LinkedList<Reference>(); } /* Also: let's not increase without bounds. Could choose either * head or tail; tail is easier (no need to ever remove), as * well as potentially more useful so let's use it: */ if (_path.size() < MAX_REFS_TO_LIST) { _path.addFirst(r); } } /* /********************************************************** /* Overridden methods /********************************************************** */ @Override public String getLocalizedMessage() { return _buildMessage(); } /** * Method is overridden so that we can properly inject description * of problem path, if such is defined. */ @Override public String getMessage() { return _buildMessage();

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> = property; _dynamicValueSerializers = PropertySerializerMap.emptyForProperties(); } @SuppressWarnings("unchecked") protected MapEntrySerializer(MapEntrySerializer src, BeanProperty property, TypeSerializer vts, JsonSerializer<?> keySer, JsonSerializer<?> valueSer) { super(Map.class, false); _entryType = src._entryType; _keyType = src._keyType; _valueType = src._valueType; _valueTypeIsStatic = src._valueTypeIsStatic; _valueTypeSerializer = src._valueTypeSerializer; _keySerializer = (JsonSerializer<Object>) keySer; _valueSerializer = (JsonSerializer<Object>) valueSer; _dynamicValueSerializers = src._dynamicValueSerializers; _property = src._property; } @Override public ContainerSerializer<?> _withValueTypeSerializer(TypeSerializer vts) { return new MapEntrySerializer(this, _property, vts, _keySerializer, _valueSerializer); } public MapEntrySerializer withResolved(BeanProperty property, JsonSerializer<?> keySerializer, JsonSerializer<?> valueSerializer) { return new MapEntrySerializer(this, property, _valueTypeSerializer, keySerializer, valueSerializer); } @Override public JsonSerializer<?> createContextual(SerializerProvider provider, BeanProperty property) throws JsonMappingException { JsonSerializer<?> ser = null; JsonSerializer<?> keySer = null; final AnnotationIntrospector intr = provider.getAnnotationIntrospector(); final AnnotatedMember propertyAcc = (property == null) ? null : property.getMember(); // First: if we have a property, may have property-annotation overrides if (propertyAcc != null && intr != null) { Object serDef = intr.findKeySerializer(propertyAcc); if (serDef != null) { keySer = provider.serializerInstance(propertyAcc, serDef); } serDef = intr.findContentSerializer(propertyAcc); if (serDef != null) { ser = provider.serializerInstance(propertyAcc, serDef); } } if (ser == null) { ser = _valueSerializer; } // [Issue#124]: May have a content converter ser = findConvertingContentSerializer(provider, property, ser); if (ser == null) { // 30-Sep

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> serialize fields, when the value type is statically known, * so that value serializer is passed and does not need to be fetched from * provider. */ protected void serializeUsing(Map.Entry<?, ?> value, JsonGenerator jgen, SerializerProvider provider, JsonSerializer<Object> ser) throws IOException, JsonGenerationException { final JsonSerializer<Object> keySerializer = _keySerializer; final TypeSerializer vts = _valueTypeSerializer; final boolean skipNulls = !provider.isEnabled(SerializationFeature.WRITE_NULL_MAP_VALUES); Object valueElem = value.getValue(); Object keyElem = value.getKey(); if (keyElem == null) { provider.findNullKeySerializer(_keyType, _property).serialize(null, jgen, provider); } else { // [JACKSON-314] also may need to skip entries with null values if (skipNulls && valueElem == null) return; keySerializer.serialize(keyElem, jgen, provider); } if (valueElem == null) { provider.defaultSerializeNull(jgen); } else { try { if (vts == null) { ser.serialize(valueElem, jgen, provider); } else { ser.serializeWithType(valueElem, jgen, provider, vts); } } catch (Exception e) { // [JACKSON-55] Need to add reference information String keyDesc = ""+keyElem; wrapAndThrow(provider, e, value, keyDesc); } } } /* /********************************************************** /* Internal helper methods /********************************************************** */ protected final JsonSerializer<Object> _findAndAddDynamic(PropertySerializerMap map, Class<?> type, SerializerProvider provider) throws JsonMappingException { PropertySerializerMap.SerializerAndMapResult result = map.findAndAddSecondarySerializer(type, provider, _property); if (map != result.map) { _dynamicValueSerializers = result.map; } return result.serializer; } protected final JsonSerializer<Object> _findAndAddDynamic(PropertySerializerMap map, JavaType type, SerializerProvider provider) throws JsonMappingException { PropertySerializerMap.SerializerAndMapResult result = map.findAndAddSecondarySerializer(type, provider

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>, JavaType type) throws JsonMappingException { if (visitor != null) visitor.expectAnyFormat(type); } /* /********************************************************** /* Helper class(es) /********************************************************** */ /** * This marker class is only to be used with annotations, to * indicate that <b>no serializer is configured</b>. *<p> * Specifically, this class is to be used as the marker for * annotation {@link com.fasterxml.jackson.databind.annotation.JsonSerialize}. */ public abstract static class None extends JsonSerializer<Object> { } }

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>package com.fasterxml.jackson.databind.ser.std; import java.io.IOException; import java.lang.reflect.Type; import com.fasterxml.jackson.core.*; import com.fasterxml.jackson.databind.JavaType; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitorWrapper; import com.fasterxml.jackson.databind.jsontype.TypeSerializer; @SuppressWarnings("serial") public abstract class StdScalarSerializer<T> extends StdSerializer<T> { protected StdScalarSerializer(Class<T> t) { super(t); } /** * Alternate constructor that is (alas!) needed to work * around kinks of generic type handling */ @SuppressWarnings("unchecked") protected StdScalarSerializer(Class<?> t, boolean dummy) { super((Class<T>) t); } /** * Default implementation will write type prefix, call regular serialization * method (since assumption is that value itself does not need JSON * Array or Object start/end markers), and then write type suffix. * This should work for most cases; some sub-classes may want to * change this behavior. */ @Override public void serializeWithType(T value, JsonGenerator jgen, SerializerProvider provider, TypeSerializer typeSer) throws IOException { typeSer.writeTypePrefixForScalar(value, jgen); serialize(value, jgen, provider); typeSer.writeTypeSuffixForScalar(value, jgen); } @Override public JsonNode getSchema(SerializerProvider provider, Type typeHint) throws JsonMappingException { return createSchemaNode("string", true); } @Override public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) throws JsonMappingException { if (visitor != null) { // 13-Sep-2013, tatu: Let's assume it's usually a String, right? // visitor.expectAnyFormat(typeHint); visitor.expectStringFormat(typeHint); } } }

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>package com.fasterxml.jackson.databind.deser; import com.fasterxml.jackson.databind.DeserializationContext; import com.fasterxml.jackson.databind.JsonMappingException; /** * Interface used to indicate deserializers that want to do post-processing * after construction but before being returned to caller (and possibly cached) * and used. * This is typically used to resolve references * to other contained types; for example, bean deserializers use this callback * to locate deserializers for contained field types. * Main reason for using a callback (instead of trying to resolve dependencies * immediately) is to make it possible to cleanly handle self-references; * otherwise it would be easy to get into infinite recursion. *<p> * Note that {@link #resolve} method does NOT allow returning anything * (specifically, a new deserializer instance): reason for this is that * allowing this would not work with proper handling of cyclic dependencies, * which are resolved by two-phase processing, where initially constructed * deserializer is added as known deserializer, and only after this * resolution is done. Resolution is the part that results in lookups for * dependant deserializers, which may include handling references to * deserializer itself. *<p> * Note that in cases where deserializer needs both contextualization and * resolution -- that is, implements both this interface and {@link ContextualDeserializer} * -- resolution via this interface occurs first, and contextual * resolution (using {@link ContextualDeserializer}) later on. */ public interface ResolvableDeserializer { /** * Method called after deserializer instance has been constructed * (and registered as necessary by provider objects), * but before it has returned it to the caller. * Called object can then resolve its dependencies to other types, * including self-references (direct or indirect). * * @param ctxt Context to use for accessing configuration, resolving * secondary deserializers */ public abstract void resolve(DeserializationContext ctxt) throws JsonMappingException; }

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> == featureMask; } public final int getDeserializationFeatures() { return _deserFeatures; } /* /********************************************************** /* Other configuration /********************************************************** */ /** * Method for getting head of the problem handler chain. May be null, * if no handlers have been added. */ public LinkedNode<DeserializationProblemHandler> getProblemHandlers() { return _problemHandlers; } public final JsonNodeFactory getNodeFactory() { return _nodeFactory; } /* /********************************************************** /* Introspection methods /********************************************************** */ /** * Method that will introspect full bean properties for the purpose * of building a bean deserializer * * @param type Type of class to be introspected */ @SuppressWarnings("unchecked") public <T extends BeanDescription> T introspect(JavaType type) { return (T) getClassIntrospector().forDeserialization(this, type, this); } /** * Method that will introspect subset of bean properties needed to * construct bean instance. */ @SuppressWarnings("unchecked") public <T extends BeanDescription> T introspectForCreation(JavaType type) { return (T) getClassIntrospector().forCreation(this, type, this); } /** * @since 2.0 */ @SuppressWarnings("unchecked") public <T extends BeanDescription> T introspectForBuilder(JavaType type) { return (T) getClassIntrospector().forDeserializationWithBuilder(this, type, this); } /* /********************************************************** /* Support for polymorphic type handling /********************************************************** */ /** * Helper method that is needed to properly handle polymorphic referenced * types, such as types referenced by {@link java.util.concurrent.atomic.AtomicReference}, * or various "optional" types. * * @since 2.4 */ public TypeDeserializer findTypeDeserializer(JavaType baseType) throws JsonMappingException { BeanDescription bean = introspectClassAnnotations(baseType.getRawClass()); AnnotatedClass ac = bean.getClassInfo(); TypeResolverBuilder<?> b = getAnnotationIntrospector().findTypeResolver(this, ac, baseType); /* Ok: if there is no explicit type info handler, we may want to * use a default

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>package com.fasterxml.jackson.databind.ser.impl; import java.util.Arrays; import com.fasterxml.jackson.databind.BeanProperty; import com.fasterxml.jackson.databind.JavaType; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.JsonSerializer; import com.fasterxml.jackson.databind.SerializerProvider; /** * Helper container used for resolving serializers for dynamic (possibly but not * necessarily polymorphic) properties: properties whose type is not forced * to use dynamic (declared) type and that are not final. * If so, serializer to use can only be established once actual value type is known. * Since this happens a lot unless static typing is forced (or types are final) * this implementation is optimized for efficiency. * Instances are immutable; new instances are created with factory methods: this * is important to ensure correct multi-threaded access. */ public abstract class PropertySerializerMap { /** * Configuration setting that determines what happens when maximum * size (currently 8) is reached: if true, will "start from beginning"; * if false, will simply stop adding new entries. * * @since 2.5 */ protected final boolean _resetWhenFull; /** * @since 2.5 */ protected PropertySerializerMap(boolean resetWhenFull) { _resetWhenFull = resetWhenFull; } protected PropertySerializerMap(PropertySerializerMap base) { _resetWhenFull = base._resetWhenFull; } /** * Main lookup method. Takes a "raw" type since usage is always from * place where parameterization is fixed such that there can not be * type-parametric variations. */ public abstract JsonSerializer<Object> serializerFor(Class<?> type); /** * Method called if initial lookup fails, when looking for a primary * serializer (one that is directly attached to a property). * Will both find serializer * and construct new map instance if warranted, and return both. * * @since 2.3 * * @throws JsonMappingException */ public final SerializerAndMapResult findAndAddPrimarySerializer(Class<?> type, SerializerProvider provider, BeanProperty property) throws JsonMappingException { JsonSerializer<Object>

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> serializer = provider.findPrimaryPropertySerializer(type, property); return new SerializerAndMapResult(serializer, newWith(type, serializer)); } public final SerializerAndMapResult findAndAddPrimarySerializer(JavaType type, SerializerProvider provider, BeanProperty property) throws JsonMappingException { JsonSerializer<Object> serializer = provider.findPrimaryPropertySerializer(type, property); return new SerializerAndMapResult(serializer, newWith(type.getRawClass(), serializer)); } /** * Method called if initial lookup fails, when looking for a non-primary * serializer (one that is not directly attached to a property). * Will both find serializer * and construct new map instance if warranted, and return both. * * @since 2.3 * * @throws JsonMappingException */ public final SerializerAndMapResult findAndAddSecondarySerializer(Class<?> type, SerializerProvider provider, BeanProperty property) throws JsonMappingException { JsonSerializer<Object> serializer = provider.findValueSerializer(type, property); return new SerializerAndMapResult(serializer, newWith(type, serializer)); } public final SerializerAndMapResult findAndAddSecondarySerializer(JavaType type, SerializerProvider provider, BeanProperty property) throws JsonMappingException { JsonSerializer<Object> serializer = provider.findValueSerializer(type, property); return new SerializerAndMapResult(serializer, newWith(type.getRawClass(), serializer)); } /** * Method called if initial lookup fails, when looking for a root value * serializer: one that is not directly attached to a property, but needs to * have {@link com.fasterxml.jackson.databind.jsontype.TypeSerializer} wrapped * around it. Will both find the serializer * and construct new map instance if warranted, and return both. * * @since 2.5 * * @throws JsonMappingException */ public final SerializerAndMapResult findAndAddRootValueSerializer(Class<?> type, SerializerProvider provider) throws JsonMappingException { JsonSerializer<Object> serializer = provider.findTypedValueSerializer(type, false, null); return new SerializerAndMapResult(serializer, newWith(type, serializer)); } /** * @since 2.5 */ public final SerializerAndMapResult

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> findAndAddRootValueSerializer(JavaType type, SerializerProvider provider) throws JsonMappingException { JsonSerializer<Object> serializer = provider.findTypedValueSerializer(type, false, null); return new SerializerAndMapResult(serializer, newWith(type.getRawClass(), serializer)); } /** * Method that can be used to 'register' a serializer that caller has resolved * without help of this map. * * @since 2.5 */ public final SerializerAndMapResult addSerializer(Class<?> type, JsonSerializer<Object> serializer) { return new SerializerAndMapResult(serializer, newWith(type, serializer)); } /** * @since 2.5 */ public final SerializerAndMapResult addSerializer(JavaType type, JsonSerializer<Object> serializer) { return new SerializerAndMapResult(serializer, newWith(type.getRawClass(), serializer)); } public abstract PropertySerializerMap newWith(Class<?> type, JsonSerializer<Object> serializer); /** * @deprecated Since 2.5 Use {@link #emptyForProperties} instead */ @Deprecated public static PropertySerializerMap emptyMap() { return emptyForProperties(); } /** * @since 2.5 */ public static PropertySerializerMap emptyForProperties() { return Empty.FOR_PROPERTIES; } /** * @since 2.5 */ public static PropertySerializerMap emptyForRootValues() { return Empty.FOR_ROOT_VALUES; } /* /********************************************************** /* Helper classes /********************************************************** */ /** * Value class used for returning tuple that has both serializer * that was retrieved and new map instance */ public final static class SerializerAndMapResult { public final JsonSerializer<Object> serializer; public final PropertySerializerMap map; public SerializerAndMapResult(JsonSerializer<Object> serializer, PropertySerializerMap map) { this.serializer = serializer; this.map = map; } } /** * Trivial container for bundling type + serializer entries. */ private final static class TypeAndSerializer { public final Class<?> type; public final JsonSerializer<Object> serializer; public TypeAndSerializer(Class<?> type, JsonSerializer<Object> serializer) { this.type = type; this.

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>package com.fasterxml.jackson.databind.introspect; import java.lang.annotation.Annotation; import java.util.*; import com.fasterxml.jackson.databind.util.Annotations; /** * Simple helper class used to keep track of collection of * Jackson Annotations associated with annotatable things * (methods, constructors, classes). * Note that only Jackson-owned annotations are tracked (for now?). */ public final class AnnotationMap implements Annotations { protected HashMap<Class<? extends Annotation>,Annotation> _annotations; public AnnotationMap() { } private AnnotationMap(HashMap<Class<? extends Annotation>,Annotation> a) { _annotations = a; } @SuppressWarnings("unchecked") @Override public <A extends Annotation> A get(Class<A> cls) { if (_annotations == null) { return null; } return (A) _annotations.get(cls); } /** * @since 2.3 */ public Iterable<Annotation> annotations() { if (_annotations == null || _annotations.size() == 0) { return Collections.emptyList(); } return _annotations.values(); } public static AnnotationMap merge(AnnotationMap primary, AnnotationMap secondary) { if (primary == null || primary._annotations == null || primary._annotations.isEmpty()) { return secondary; } if (secondary == null || secondary._annotations == null || secondary._annotations.isEmpty()) { return primary; } HashMap<Class<? extends Annotation>,Annotation> annotations = new HashMap<Class<? extends Annotation>,Annotation>(); // add secondary ones first for (Annotation ann : secondary._annotations.values()) { annotations.put(ann.annotationType(), ann); } // to be overridden by primary ones for (Annotation ann : primary._annotations.values()) { annotations.put(ann.annotationType(), ann); } return new AnnotationMap(annotations); } @Override public int size() { return (_annotations == null) ? 0 : _annotations.size(); } /** * Method called to add specified annotation in the Map, but * only if it didn't yet exist. */ public boolean addIfNotPresent(Annotation ann) { if (_annotations == null || !_annotations.containsKey(

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>ann.annotationType())) { _add(ann); return true; } return false; } /** * Method called to add specified annotation in the Map. */ public boolean add(Annotation ann) { return _add(ann); } @Override public String toString() { if (_annotations == null) { return "[null]"; } return _annotations.toString(); } /* /********************************************************** /* Helper methods /********************************************************** */ protected final boolean _add(Annotation ann) { if (_annotations == null) { _annotations = new HashMap<Class<? extends Annotation>,Annotation>(); } Annotation previous = _annotations.put(ann.annotationType(), ann); return (previous != null) && previous.equals(ann); } }

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>ors /********************************************************** */ @Override public Class<T> handledType() { return _handledType; } /* /********************************************************** /* Serialization /********************************************************** */ @Override public abstract void serialize(T value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonGenerationException; /* /********************************************************** /* Helper methods for JSON Schema generation /********************************************************** */ /** * Default implementation simply claims type is "string"; usually * overriden by custom serializers. */ @Override public JsonNode getSchema(SerializerProvider provider, Type typeHint) throws JsonMappingException { return createSchemaNode("string"); } /** * Default implementation simply claims type is "string"; usually * overriden by custom serializers. */ @Override public JsonNode getSchema(SerializerProvider provider, Type typeHint, boolean isOptional) throws JsonMappingException { ObjectNode schema = (ObjectNode) getSchema(provider, typeHint); if (!isOptional) { schema.put("required", !isOptional); } return schema; } protected ObjectNode createObjectNode() { return JsonNodeFactory.instance.objectNode(); } protected ObjectNode createSchemaNode(String type) { ObjectNode schema = createObjectNode(); schema.put("type", type); return schema; } protected ObjectNode createSchemaNode(String type, boolean isOptional) { ObjectNode schema = createSchemaNode(type); // as per [JACKSON-563]. Note that 'required' defaults to false if (!isOptional) { schema.put("required", !isOptional); } return schema; } /** * Default implementation specifies no format. This behavior is usually * overriden by custom serializers. */ @Override public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) throws JsonMappingException { visitor.expectAnyFormat(typeHint); } /* /********************************************************** /* Helper methods for exception handling /********************************************************** */ /** * Method that will modify caught exception (passed in as argument) * as necessary to include reference information, and to ensure it * is a subtype of {@link IOException}, or an unchecked

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> exception. *<p> * Rules for wrapping and unwrapping are bit complicated; essentially: *<ul> * <li>Errors are to be passed as is (if uncovered via unwrapping) * <li>"Plain" IOExceptions (ones that are not of type * {@link JsonMappingException} are to be passed as is *</ul> */ public void wrapAndThrow(SerializerProvider provider, Throwable t, Object bean, String fieldName) throws IOException { /* 05-Mar-2009, tatu: But one nasty edge is when we get * StackOverflow: usually due to infinite loop. But that * usually gets hidden within an InvocationTargetException... */ while (t instanceof InvocationTargetException && t.getCause() != null) { t = t.getCause(); } // Errors and "plain" IOExceptions to be passed as is if (t instanceof Error) { throw (Error) t; } // Ditto for IOExceptions... except for mapping exceptions! boolean wrap = (provider == null) || provider.isEnabled(SerializationFeature.WRAP_EXCEPTIONS); if (t instanceof IOException) { if (!wrap || !(t instanceof JsonMappingException)) { throw (IOException) t; } } else if (!wrap) { // [JACKSON-407] -- allow disabling wrapping for unchecked exceptions if (t instanceof RuntimeException) { throw (RuntimeException) t; } } // [JACKSON-55] Need to add reference information throw JsonMappingException.wrapWithPath(t, bean, fieldName); } public void wrapAndThrow(SerializerProvider provider, Throwable t, Object bean, int index) throws IOException { while (t instanceof InvocationTargetException && t.getCause() != null) { t = t.getCause(); } // Errors are to be passed as is if (t instanceof Error) { throw (Error) t; } // Ditto for IOExceptions... except for mapping exceptions! boolean wrap = (provider == null) || provider.isEnabled(SerializationFeature.WRAP_EXCEPTIONS); if (t instanceof IOException) { if (!wrap || !(t instanceof JsonMappingException)) { throw (IOException) t; } }

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> else if (!wrap) { // [JACKSON-407] -- allow disabling wrapping for unchecked exceptions if (t instanceof RuntimeException) { throw (RuntimeException) t; } } // [JACKSON-55] Need to add reference information throw JsonMappingException.wrapWithPath(t, bean, index); } /* /********************************************************** /* Helper methods, other /********************************************************** */ /** * Method that can be called to determine if given serializer is the default * serializer Jackson uses; as opposed to a custom serializer installed by * a module or calling application. Determination is done using * {@link JacksonStdImpl} annotation on serializer class. */ protected boolean isDefaultSerializer(JsonSerializer<?> serializer) { return ClassUtil.isJacksonStdImpl(serializer); } /** * Helper method that can be used to see if specified property has annotation * indicating that a converter is to be used for contained values (contents * of structured types; array/List/Map values) * * @param existingSerializer (optional) configured content * serializer if one already exists. * * @since 2.2 */ protected JsonSerializer<?> findConvertingContentSerializer(SerializerProvider provider, BeanProperty prop, JsonSerializer<?> existingSerializer) throws JsonMappingException { /* 19-Oct-2014, tatu: As per [databind#357], need to avoid infinite loop * when applying contextual content converter; this is not ideal way, * but should work for most cases. */ final AnnotationIntrospector intr = provider.getAnnotationIntrospector(); if (intr != null && prop != null) { AnnotatedMember m = prop.getMember(); if (m != null) { Object convDef = intr.findSerializationContentConverter(m); if (convDef != null) { Converter<Object,Object> conv = provider.converterInstance(prop.getMember(), convDef); JavaType delegateType = conv.getOutputType(provider.getTypeFactory()); if (existingSerializer == null) { existingSerializer = provider.findValueSerializer(delegateType); } return new StdDelegatingSerializer(conv, delegateType, existingSerializer); } } } return existingSerializer; }

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> /** * Helper method used to locate filter that is needed, based on filter id * this serializer was constructed with. * * @since 2.3 */ protected PropertyFilter findPropertyFilter(SerializerProvider provider, Object filterId, Object valueToFilter) throws JsonMappingException { FilterProvider filters = provider.getFilterProvider(); // Not ok to miss the provider, if a filter is declared to be needed. if (filters == null) { throw new JsonMappingException("Can not resolve PropertyFilter with id '"+filterId+"'; no FilterProvider configured"); } PropertyFilter filter = filters.findPropertyFilter(filterId, valueToFilter); // But whether unknown ids are ok just depends on filter provider; if we get null that's fine return filter; } }

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>processing (ResolvableDeserializer) /********************************************************** */ /** * Method called to finalize setup of this deserializer, * when it is known for which property deserializer is needed * for. */ @Override public CollectionDeserializer createContextual(DeserializationContext ctxt, BeanProperty property) throws JsonMappingException { // May need to resolve types for delegate-based creators: JsonDeserializer<Object> delegateDeser = null; if ((_valueInstantiator != null) && _valueInstantiator.canCreateUsingDelegate()) { JavaType delegateType = _valueInstantiator.getDelegateType(ctxt.getConfig()); if (delegateType == null) { throw new IllegalArgumentException("Invalid delegate-creator definition for "+_collectionType +": value instantiator ("+_valueInstantiator.getClass().getName() +") returned true for 'canCreateUsingDelegate()', but null for 'getDelegateType()'"); } delegateDeser = findDeserializer(ctxt, delegateType, property); } // also, often value deserializer is resolved here: JsonDeserializer<?> valueDeser = _valueDeserializer; // #125: May have a content converter valueDeser = findConvertingContentDeserializer(ctxt, property, valueDeser); final JavaType vt = _collectionType.getContentType(); if (valueDeser == null) { valueDeser = ctxt.findContextualValueDeserializer(vt, property); } else { // if directly assigned, probably not yet contextual, so: valueDeser = ctxt.handleSecondaryContextualization(valueDeser, property, vt); } // and finally, type deserializer needs context as well TypeDeserializer valueTypeDeser = _valueTypeDeserializer; if (valueTypeDeser != null) { valueTypeDeser = valueTypeDeser.forProperty(property); } return withResolved(delegateDeser, valueDeser, valueTypeDeser); } /* /********************************************************** /* ContainerDeserializerBase API /********************************************************** */ @Override public JavaType getContentType() { return _collectionType.getContentType(); } @Override public JsonDeserializer<Object> getContentDeserializer() { return _valueDeserializer; } /* /********************************************************** /* JsonDeserializer API /********************************************************** */ @SuppressWarnings("unchecked

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>resolvedForwardReference reference) { if (referringAccumulator == null) { throw JsonMappingException .from(p, "Unresolved forward reference but no identity info", reference); } Referring ref = referringAccumulator.handleUnresolvedReference(reference); reference.getRoid().appendReferring(ref); } catch (Exception e) { throw JsonMappingException.wrapWithPath(e, result, result.size()); } } return result; } @Override public Object deserializeWithType(JsonParser jp, DeserializationContext ctxt, TypeDeserializer typeDeserializer) throws IOException { // In future could check current token... for now this should be enough: return typeDeserializer.deserializeTypedFromArray(jp, ctxt); } /** * Helper method called when current token is no START_ARRAY. Will either * throw an exception, or try to handle value as if member of implicit * array, depending on configuration. */ protected final Collection<Object> handleNonArray(JsonParser p, DeserializationContext ctxt, Collection<Object> result) throws IOException { // [JACKSON-526]: implicit arrays from single values? if (!ctxt.isEnabled(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY)) { throw ctxt.mappingException(_collectionType.getRawClass()); } JsonDeserializer<Object> valueDes = _valueDeserializer; final TypeDeserializer typeDeser = _valueTypeDeserializer; JsonToken t = p.getCurrentToken(); Object value; try { if (t == JsonToken.VALUE_NULL) { value = valueDes.getNullValue(); } else if (typeDeser == null) { value = valueDes.deserialize(p, ctxt); } else { value = valueDes.deserializeWithType(p, ctxt, typeDeser); } } catch (Exception e) { // note: pass Object.class, not Object[].class, as we need element type for error info throw JsonMappingException.wrapWithPath(e, Object.class, result.size()); } result.add(value); return result; } public final static class CollectionReferringAccumulator { private final Class<?> _elementType; private final Collection<Object> _result; /** * A list of {@link CollectionRef

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> if (!found && bucket.key.equals(name)) { found = true; } else { tail = new Bucket(tail, bucket.key, bucket.value, bucket.index); } } if (!found) { // must be found throw new NoSuchElementException("No entry '"+property+"' found, can't remove"); } _buckets[index] = tail; } /* /********************************************************** /* Helper methods /********************************************************** */ private SettableBeanProperty _findWithEquals(String key, int index) { Bucket bucket = _buckets[index]; while (bucket != null) { if (key.equals(bucket.key)) { return bucket.value; } bucket = bucket.next; } return null; } /** * @since 2.5 */ protected void wrapAndThrow(Throwable t, Object bean, String fieldName, DeserializationContext ctxt) throws IOException { // inlined 'throwOrReturnThrowable' while (t instanceof InvocationTargetException && t.getCause() != null) { t = t.getCause(); } // Errors to be passed as is if (t instanceof Error) { throw (Error) t; } // StackOverflowErrors are tricky ones; need to be careful... boolean wrap = (ctxt == null) || ctxt.isEnabled(DeserializationFeature.WRAP_EXCEPTIONS); // Ditto for IOExceptions; except we may want to wrap JSON exceptions if (t instanceof IOException) { if (!wrap || !(t instanceof JsonProcessingException)) { throw (IOException) t; } } else if (!wrap) { // [JACKSON-407] -- allow disabling wrapping for unchecked exceptions if (t instanceof RuntimeException) { throw (RuntimeException) t; } } throw JsonMappingException.wrapWithPath(t, bean, fieldName); } /* /********************************************************** /* Helper beans /********************************************************** */ private final static class Bucket implements java.io.Serializable { private static final long serialVersionUID = 1L; public final Bucket next; public final String key; public final SettableBeanProperty value; /** * Index that indicates insertion order of the bucket */ public final int index; public Bucket(Bucket

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> need a placeholder for creator properties that don't have name * but are marked with `@JsonWrapped` annotation. */ protected final static PropertyName UNWRAPPED_CREATOR_PARAM_NAME = new PropertyName("@JsonUnwrapped"); /* We do some defaulting for abstract Map classes and * interfaces, to avoid having to use exact types or annotations in * cases where the most common concrete Maps will do. */ @SuppressWarnings("rawtypes") final static HashMap<String, Class<? extends Map>> _mapFallbacks = new HashMap<String, Class<? extends Map>>(); static { _mapFallbacks.put(Map.class.getName(), LinkedHashMap.class); _mapFallbacks.put(ConcurrentMap.class.getName(), ConcurrentHashMap.class); _mapFallbacks.put(SortedMap.class.getName(), TreeMap.class); _mapFallbacks.put(java.util.NavigableMap.class.getName(), TreeMap.class); _mapFallbacks.put(java.util.concurrent.ConcurrentNavigableMap.class.getName(), java.util.concurrent.ConcurrentSkipListMap.class); } /* We do some defaulting for abstract Collection classes and * interfaces, to avoid having to use exact types or annotations in * cases where the most common concrete Collection will do. */ @SuppressWarnings("rawtypes") final static HashMap<String, Class<? extends Collection>> _collectionFallbacks = new HashMap<String, Class<? extends Collection>>(); static { _collectionFallbacks.put(Collection.class.getName(), ArrayList.class); _collectionFallbacks.put(List.class.getName(), ArrayList.class); _collectionFallbacks.put(Set.class.getName(), HashSet.class); _collectionFallbacks.put(SortedSet.class.getName(), TreeSet.class); _collectionFallbacks.put(Queue.class.getName(), LinkedList.class); // then 1.6 types: /* 17-May-2013, tatu: [Issue#216] Should be fine to use straight Class references EXCEPT * that some godforsaken platforms (... looking at you, Android) do not * include these. So, use "soft" references... */ _collectionFallbacks.put("java.util.Deque", LinkedList

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>.class); _collectionFallbacks.put("java.util.NavigableSet", TreeSet.class); } /* /********************************************************** /* Config /********************************************************** */ /** * Configuration settings for this factory; immutable instance (just like this * factory), new version created via copy-constructor (fluent-style) */ protected final DeserializerFactoryConfig _factoryConfig; /* /********************************************************** /* Life cycle /********************************************************** */ protected BasicDeserializerFactory(DeserializerFactoryConfig config) { _factoryConfig = config; } /** * Method for getting current {@link DeserializerFactoryConfig}. *<p> * Note that since instances are immutable, you can NOT change settings * by accessing an instance and calling methods: this will simply create * new instance of config object. */ public DeserializerFactoryConfig getFactoryConfig() { return _factoryConfig; } protected abstract DeserializerFactory withConfig(DeserializerFactoryConfig config); /* /******************************************************** /* Configuration handling: fluent factories /******************************************************** */ /** * Convenience method for creating a new factory instance with additional deserializer * provider. */ @Override public final DeserializerFactory withAdditionalDeserializers(Deserializers additional) { return withConfig(_factoryConfig.withAdditionalDeserializers(additional)); } /** * Convenience method for creating a new factory instance with additional * {@link KeyDeserializers}. */ @Override public final DeserializerFactory withAdditionalKeyDeserializers(KeyDeserializers additional) { return withConfig(_factoryConfig.withAdditionalKeyDeserializers(additional)); } /** * Convenience method for creating a new factory instance with additional * {@link BeanDeserializerModifier}. */ @Override public final DeserializerFactory withDeserializerModifier(BeanDeserializerModifier modifier) { return withConfig(_factoryConfig.withDeserializerModifier(modifier)); } /** * Convenience method for creating a new factory instance with additional * {@link AbstractTypeResolver}. */ @Override public final DeserializerFactory withAbstractTypeResolver(AbstractTypeResolver resolver) { return withConfig(_factoryConfig.withAbstractTypeResolver(resolver)); } /** * Convenience method for creating a new factory instance with additional * {@link ValueInstantiators}. */ @Override public final DeserializerFactory withValueInstantiators

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>(ValueInstantiators instantiators) { return withConfig(_factoryConfig.withValueInstantiators(instantiators)); } /* /********************************************************** /* JsonDeserializerFactory impl (partial): type mappings /********************************************************** */ @Override public JavaType mapAbstractType(DeserializationConfig config, JavaType type) throws JsonMappingException { // first, general mappings while (true) { JavaType next = _mapAbstractType2(config, type); if (next == null) { return type; } /* Should not have to worry about cycles; but better verify since they will invariably * occur... :-) * (also: guard against invalid resolution to a non-related type) */ Class<?> prevCls = type.getRawClass(); Class<?> nextCls = next.getRawClass(); if ((prevCls == nextCls) || !prevCls.isAssignableFrom(nextCls)) { throw new IllegalArgumentException("Invalid abstract type resolution from "+type+" to "+next+": latter is not a subtype of former"); } type = next; } } /** * Method that will find abstract type mapping for specified type, doing a single * lookup through registered abstract type resolvers; will not do recursive lookups. */ private JavaType _mapAbstractType2(DeserializationConfig config, JavaType type) throws JsonMappingException { Class<?> currClass = type.getRawClass(); if (_factoryConfig.hasAbstractTypeResolvers()) { for (AbstractTypeResolver resolver : _factoryConfig.abstractTypeResolvers()) { JavaType concrete = resolver.findTypeMapping(config, type); if (concrete != null && concrete.getRawClass() != currClass) { return concrete; } } } return null; } /* /********************************************************** /* JsonDeserializerFactory impl (partial): ValueInstantiators /********************************************************** */ /** * Value instantiator is created both based on creator annotations, * and on optional externally provided instantiators (registered through * module interface). */ @Override public ValueInstantiator findValueInstantiator(DeserializationContext ctxt, BeanDescription beanDesc) throws JsonMappingException { final DeserializationConfig config = ctxt.getConfig(); ValueInstantiator instantiator = null; // [JACKSON-633] Check

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> @JsonValueInstantiator before anything else AnnotatedClass ac = beanDesc.getClassInfo(); Object instDef = ctxt.getAnnotationIntrospector().findValueInstantiator(ac); if (instDef != null) { instantiator = _valueInstantiatorInstance(config, ac, instDef); } if (instantiator == null) { /* Second: see if some of standard Jackson/JDK types might provide value * instantiators. */ instantiator = _findStdValueInstantiator(config, beanDesc); if (instantiator == null) { instantiator = _constructDefaultValueInstantiator(ctxt, beanDesc); } } // finally: anyone want to modify ValueInstantiator? if (_factoryConfig.hasValueInstantiators()) { for (ValueInstantiators insts : _factoryConfig.valueInstantiators()) { instantiator = insts.findValueInstantiator(config, beanDesc, instantiator); // let's do sanity check; easier to spot buggy handlers if (instantiator == null) { throw new JsonMappingException("Broken registered ValueInstantiators (of type " +insts.getClass().getName()+"): returned null ValueInstantiator"); } } } // Sanity check: does the chosen instantatior have incomplete creators? if (instantiator.getIncompleteParameter() != null) { final AnnotatedParameter nonAnnotatedParam = instantiator.getIncompleteParameter(); final AnnotatedWithParams ctor = nonAnnotatedParam.getOwner(); throw new IllegalArgumentException("Argument #"+nonAnnotatedParam.getIndex()+" of constructor "+ctor+" has no property name annotation; must have name when multiple-parameter constructor annotated as Creator"); } return instantiator; } private ValueInstantiator _findStdValueInstantiator(DeserializationConfig config, BeanDescription beanDesc) throws JsonMappingException { if (beanDesc.getBeanClass() == JsonLocation.class) { return new JsonLocationInstantiator(); } return null; } /** * Method that will construct standard default {@link ValueInstantiator} * using annotations (like @JsonCreator) and visibility rules */ protected ValueInstantiator _constructDefaultValueInstantiator(DeserializationContext ctxt, BeanDescription beanDesc) throws JsonMappingException { boolean fixAccess = ctxt.canOverrideAccessModifiers();

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> CreatorCollector creators = new CreatorCollector(beanDesc, fixAccess); AnnotationIntrospector intr = ctxt.getAnnotationIntrospector(); // need to construct suitable visibility checker: final DeserializationConfig config = ctxt.getConfig(); VisibilityChecker<?> vchecker = config.getDefaultVisibilityChecker(); vchecker = intr.findAutoDetectVisibility(beanDesc.getClassInfo(), vchecker); /* 24-Sep-2014, tatu: Tricky part first; need to merge resolved property information * (which has creator parameters sprinkled around) with actual creator * declarations (which are needed to access creator annotation, amongst other things). * Easiest to combine that info first, then pass it to remaining processing. */ Map<AnnotatedWithParams,BeanPropertyDefinition[]> creatorDefs = _findCreatorsFromProperties(ctxt, beanDesc); /* Important: first add factory methods; then constructors, so * latter can override former! */ _addDeserializerFactoryMethods(ctxt, beanDesc, vchecker, intr, creators, creatorDefs); // constructors only usable on concrete types: if (beanDesc.getType().isConcrete()) { _addDeserializerConstructors(ctxt, beanDesc, vchecker, intr, creators, creatorDefs); } return creators.constructValueInstantiator(config); } protected Map<AnnotatedWithParams,BeanPropertyDefinition[]> _findCreatorsFromProperties(DeserializationContext ctxt, BeanDescription beanDesc) throws JsonMappingException { Map<AnnotatedWithParams,BeanPropertyDefinition[]> result = Collections.emptyMap(); for (BeanPropertyDefinition propDef : beanDesc.findProperties()) { Iterator<AnnotatedParameter> it = propDef.getConstructorParameters(); while (it.hasNext()) { AnnotatedParameter param = it.next(); AnnotatedWithParams owner = param.getOwner(); BeanPropertyDefinition[] defs = result.get(owner); final int index = param.getIndex(); if (defs == null) { if (result.isEmpty()) { result = new LinkedHashMap<AnnotatedWithParams,BeanPropertyDefinition[]>(); } defs = new BeanPropertyDefinition[owner.getParameterCount()]; result.put(owner, defs); } else { if (defs[index] != null) { throw new IllegalStateException("Conflict: parameter

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> #"+index+" of "+owner +" bound to more than one property; "+defs[index]+" vs "+propDef); } } defs[index] = propDef; } } return result; } public ValueInstantiator _valueInstantiatorInstance(DeserializationConfig config, Annotated annotated, Object instDef) throws JsonMappingException { if (instDef == null) { return null; } ValueInstantiator inst; if (instDef instanceof ValueInstantiator) { return (ValueInstantiator) instDef; } if (!(instDef instanceof Class)) { throw new IllegalStateException("AnnotationIntrospector returned key deserializer definition of type " +instDef.getClass().getName() +"; expected type KeyDeserializer or Class<KeyDeserializer> instead"); } Class<?> instClass = (Class<?>)instDef; if (ClassUtil.isBogusClass(instClass)) { return null; } if (!ValueInstantiator.class.isAssignableFrom(instClass)) { throw new IllegalStateException("AnnotationIntrospector returned Class "+instClass.getName() +"; expected Class<ValueInstantiator>"); } HandlerInstantiator hi = config.getHandlerInstantiator(); if (hi != null) { inst = hi.valueInstantiatorInstance(config, annotated, instClass); if (inst != null) { return inst; } } return (ValueInstantiator) ClassUtil.createInstance(instClass, config.canOverrideAccessModifiers()); } @Deprecated // since 2.5.0, removed from 2.6.0 protected void _addDeserializerConstructors(DeserializationContext ctxt, BeanDescription beanDesc, VisibilityChecker<?> vchecker, AnnotationIntrospector intr, CreatorCollector creators) throws JsonMappingException { _addDeserializerConstructors(ctxt, beanDesc, vchecker, intr, creators, Collections.<AnnotatedWithParams,BeanPropertyDefinition[]>emptyMap()); } protected void _addDeserializerConstructors (DeserializationContext ctxt, BeanDescription beanDesc, VisibilityChecker<?> vchecker, AnnotationIntrospector intr, CreatorCollector creators, Map<AnnotatedWithParams,BeanPropertyDefinition[]> creatorParams) throws JsonMappingException { // First things first: the "default constructor" (zero-arg

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>(); if ((ix == 0) && ClassUtil.isNonStaticInnerClass(ctor.getDeclaringClass())) { throw new IllegalArgumentException("Non-static inner classes like " +ctor.getDeclaringClass().getName()+" can not use @JsonCreator for constructors"); } throw new IllegalArgumentException("Argument #"+ix +" of constructor "+ctor+" has no property name annotation; must have name when multiple-parameter constructor annotated as Creator"); } } } } protected boolean _checkIfCreatorPropertyBased(AnnotationIntrospector intr, AnnotatedWithParams creator, BeanPropertyDefinition propDef) { JsonCreator.Mode mode = intr.findCreatorBinding(creator); if (mode == JsonCreator.Mode.PROPERTIES) { return true; } if (mode == JsonCreator.Mode.DELEGATING) { return false; } // If explicit name, or inject id, property-based if (((propDef != null) && propDef.isExplicitlyNamed()) || (intr.findInjectableValueId(creator.getParameter(0)) != null)) { return true; } if (propDef != null) { // One more thing: if implicit name matches property with a getter // or field, we'll consider it property-based as well String implName = propDef.getName(); if (implName != null && !implName.isEmpty()) { if (propDef.couldSerialize()) { return true; } } } // in absence of everything else, default to delegating return false; } protected boolean _handleSingleArgumentConstructor(DeserializationContext ctxt, BeanDescription beanDesc, VisibilityChecker<?> vchecker, AnnotationIntrospector intr, CreatorCollector creators, AnnotatedConstructor ctor, boolean isCreator, boolean isVisible) throws JsonMappingException { // otherwise either 'simple' number, String, or general delegate: Class<?> type = ctor.getRawParameterType(0); if (type == String.class || type == CharSequence.class) { if (isCreator || isVisible) { creators.addStringCreator(ctor, isCreator); } return true; } if (type == int.class || type == Integer.class) { if (isCreator || isVisible) { creators.addInt

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>Creator(ctor, isCreator); } return true; } if (type == long.class || type == Long.class) { if (isCreator || isVisible) { creators.addLongCreator(ctor, isCreator); } return true; } if (type == double.class || type == Double.class) { if (isCreator || isVisible) { creators.addDoubleCreator(ctor, isCreator); } return true; } if (type == boolean.class || type == Boolean.class) { if (isCreator || isVisible) { creators.addBooleanCreator(ctor, isCreator); } return true; } // Delegating Creator ok iff it has @JsonCreator (etc) if (isCreator) { creators.addDelegatingCreator(ctor, isCreator, null); return true; } return false; } @Deprecated // since 2.5, remove from 2.6 protected void _addDeserializerFactoryMethods(DeserializationContext ctxt, BeanDescription beanDesc, VisibilityChecker<?> vchecker, AnnotationIntrospector intr, CreatorCollector creators) throws JsonMappingException { _addDeserializerFactoryMethods(ctxt, beanDesc, vchecker, intr, creators, Collections.<AnnotatedWithParams,BeanPropertyDefinition[]>emptyMap()); } protected void _addDeserializerFactoryMethods (DeserializationContext ctxt, BeanDescription beanDesc, VisibilityChecker<?> vchecker, AnnotationIntrospector intr, CreatorCollector creators, Map<AnnotatedWithParams,BeanPropertyDefinition[]> creatorParams) throws JsonMappingException { final DeserializationConfig config = ctxt.getConfig(); for (AnnotatedMethod factory : beanDesc.getFactoryMethods()) { final boolean isCreator = intr.hasCreatorAnnotation(factory); final int argCount = factory.getParameterCount(); // zero-arg methods must be annotated; if so, are "default creators" [JACKSON-850] if (argCount == 0) { if (isCreator) { creators.setDefaultCreator(factory); } continue; } final BeanPropertyDefinition[] propDefs = creatorParams.get(factory); // some single-arg factory methods (String, number) are auto-detected if (argCount ==

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>, param, injectId); continue; } } /* 25-Sep-2014, tatu: Actually, we may end up "losing" naming due to higher-priority constructor * (see TestCreators#testConstructorCreator() test). And just to avoid running into that problem, * let's add one more work around */ /* PropertyName name2 = _findExplicitParamName(param, intr); if (name2 != null && !name2.isEmpty()) { // Hmmh. Ok, fine. So what are we to do with it... ? // For now... skip. May need to revisit this, should this become problematic continue main_loop; } */ if (nonAnnotatedParam == null) { nonAnnotatedParam = param; } } final int namedCount = explicitNameCount + implicitNameCount; // Ok: if named or injectable, we have more work to do if (isCreator || explicitNameCount > 0 || injectCount > 0) { // simple case; everything covered: if ((namedCount + injectCount) == argCount) { creators.addPropertyCreator(factory, isCreator, properties); } else if ((explicitNameCount == 0) && ((injectCount + 1) == argCount)) { // [712] secondary: all but one injectable, one un-annotated (un-named) creators.addDelegatingCreator(factory, isCreator, properties); } else { // otherwise, epic fail throw new IllegalArgumentException("Argument #"+nonAnnotatedParam.getIndex() +" of factory method "+factory+" has no property name annotation; must have name when multiple-parameter constructor annotated as Creator"); } } } } protected boolean _handleSingleArgumentFactory(DeserializationConfig config, BeanDescription beanDesc, VisibilityChecker<?> vchecker, AnnotationIntrospector intr, CreatorCollector creators, AnnotatedMethod factory, boolean isCreator) throws JsonMappingException { Class<?> type = factory.getRawParameterType(0); if (type == String.class || type == CharSequence.class) { if (isCreator || vchecker.isCreatorVisible(factory)) { creators.addStringCreator(factory, isCreator); } return true; }

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> if (type == int.class || type == Integer.class) { if (isCreator || vchecker.isCreatorVisible(factory)) { creators.addIntCreator(factory, isCreator); } return true; } if (type == long.class || type == Long.class) { if (isCreator || vchecker.isCreatorVisible(factory)) { creators.addLongCreator(factory, isCreator); } return true; } if (type == double.class || type == Double.class) { if (isCreator || vchecker.isCreatorVisible(factory)) { creators.addDoubleCreator(factory, isCreator); } return true; } if (type == boolean.class || type == Boolean.class) { if (isCreator || vchecker.isCreatorVisible(factory)) { creators.addBooleanCreator(factory, isCreator); } return true; } if (isCreator) { creators.addDelegatingCreator(factory, isCreator, null); return true; } return false; } /** * Method that will construct a property object that represents * a logical property passed via Creator (constructor or static * factory method) */ protected CreatorProperty constructCreatorProperty(DeserializationContext ctxt, BeanDescription beanDesc, PropertyName name, int index, AnnotatedParameter param, Object injectableValueId) throws JsonMappingException { final DeserializationConfig config = ctxt.getConfig(); final AnnotationIntrospector intr = ctxt.getAnnotationIntrospector(); PropertyMetadata metadata; { if (intr == null) { metadata = PropertyMetadata.STD_REQUIRED_OR_OPTIONAL; } else { Boolean b = intr.hasRequiredMarker(param); boolean req = (b != null && b.booleanValue()); String desc = intr.findPropertyDescription(param); Integer idx = intr.findPropertyIndex(param); String def = intr.findPropertyDefaultValue(param); metadata = PropertyMetadata.construct(req, desc, idx, def); } } JavaType t0 = config.getTypeFactory().constructType(param.getParameterType(), beanDesc.bindingsForBeanType()); BeanProperty.Std property = new BeanProperty.Std(name, t0,

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> null; } protected PropertyName _findImplicitParamName(AnnotatedParameter param, AnnotationIntrospector intr) { String str = intr.findImplicitPropertyName(param); if (str != null && !str.isEmpty()) { return new PropertyName(str); } return null; } protected boolean _hasExplicitParamName(AnnotatedParameter param, AnnotationIntrospector intr) { if (param != null && intr != null) { PropertyName n = intr.findNameForDeserialization(param); return (n != null) && n.hasSimpleName(); } return false; } /* /********************************************************** /* JsonDeserializerFactory impl: array deserializers /********************************************************** */ @Override public JsonDeserializer<?> createArrayDeserializer(DeserializationContext ctxt, ArrayType type, final BeanDescription beanDesc) throws JsonMappingException { final DeserializationConfig config = ctxt.getConfig(); JavaType elemType = type.getContentType(); // Very first thing: is deserializer hard-coded for elements? JsonDeserializer<Object> contentDeser = elemType.getValueHandler(); // Then optional type info: if type has been resolved, we may already know type deserializer: TypeDeserializer elemTypeDeser = elemType.getTypeHandler(); // but if not, may still be possible to find: if (elemTypeDeser == null) { elemTypeDeser = findTypeDeserializer(config, elemType); } // 23-Nov-2010, tatu: Custom array deserializer? JsonDeserializer<?> deser = _findCustomArrayDeserializer(type, config, beanDesc, elemTypeDeser, contentDeser); if (deser == null) { if (contentDeser == null) { Class<?> raw = elemType.getRawClass(); if (elemType.isPrimitive()) { return PrimitiveArrayDeserializers.forType(raw); } else if (raw == String.class) { return StringArrayDeserializer.instance; } } deser = new ObjectArrayDeserializer(type, contentDeser, elemTypeDeser); } // and then new with 2.2: ability to post-process it too (Issue#120) if (_factoryConfig.hasDeserializerModifiers()) { for (BeanDeserializerModifier

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> mod : _factoryConfig.deserializerModifiers()) { deser = mod.modifyArrayDeserializer(config, type, beanDesc, deser); } } return deser; } /* /********************************************************** /* JsonDeserializerFactory impl: Collection(-like) deserializers /********************************************************** */ @Override public JsonDeserializer<?> createCollectionDeserializer(DeserializationContext ctxt, CollectionType type, BeanDescription beanDesc) throws JsonMappingException { JavaType contentType = type.getContentType(); // Very first thing: is deserializer hard-coded for elements? JsonDeserializer<Object> contentDeser = contentType.getValueHandler(); final DeserializationConfig config = ctxt.getConfig(); // Then optional type info (1.5): if type has been resolved, we may already know type deserializer: TypeDeserializer contentTypeDeser = contentType.getTypeHandler(); // but if not, may still be possible to find: if (contentTypeDeser == null) { contentTypeDeser = findTypeDeserializer(config, contentType); } // 23-Nov-2010, tatu: Custom deserializer? JsonDeserializer<?> deser = _findCustomCollectionDeserializer(type, config, beanDesc, contentTypeDeser, contentDeser); if (deser == null) { Class<?> collectionClass = type.getRawClass(); if (contentDeser == null) { // not defined by annotation // One special type: EnumSet: if (EnumSet.class.isAssignableFrom(collectionClass)) { deser = new EnumSetDeserializer(contentType, null); } } } /* One twist: if we are being asked to instantiate an interface or * abstract Collection, we need to either find something that implements * the thing, or give up. * * Note that we do NOT try to guess based on secondary interfaces * here; that would probably not work correctly since casts would * fail later on (as the primary type is not the interface we'd * be implementing) */ if (deser == null) { if (type.isInterface() || type.isAbstract()) { CollectionType implType = _mapAbstractCollectionType(type, config); if (implType == null) { // [Issue#292]: Actually, may be fine, but only if polymorphich

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> deser enabled if (type.getTypeHandler() == null) { throw new IllegalArgumentException("Can not find a deserializer for non-concrete Collection type "+type); } deser = AbstractDeserializer.constructForNonPOJO(beanDesc); } else { type = implType; // But if so, also need to re-check creators... beanDesc = config.introspectForCreation(type); } } if (deser == null) { ValueInstantiator inst = findValueInstantiator(ctxt, beanDesc); if (!inst.canCreateUsingDefault()) { // [Issue#161]: No default constructor for ArrayBlockingQueue... if (type.getRawClass() == ArrayBlockingQueue.class) { return new ArrayBlockingQueueDeserializer(type, contentDeser, contentTypeDeser, inst, null); } } // 13-Dec-2010, tatu: Can use more optimal deserializer if content type is String, so: if (contentType.getRawClass() == String.class) { // no value type deserializer because Strings are one of natural/native types: deser = new StringCollectionDeserializer(type, contentDeser, inst); } else { deser = new CollectionDeserializer(type, contentDeser, contentTypeDeser, inst); } } } // and then new with 2.2: ability to post-process it too (Issue#120) if (_factoryConfig.hasDeserializerModifiers()) { for (BeanDeserializerModifier mod : _factoryConfig.deserializerModifiers()) { deser = mod.modifyCollectionDeserializer(config, type, beanDesc, deser); } } return deser; } protected CollectionType _mapAbstractCollectionType(JavaType type, DeserializationConfig config) { Class<?> collectionClass = type.getRawClass(); collectionClass = _collectionFallbacks.get(collectionClass.getName()); if (collectionClass == null) { return null; } return (CollectionType) config.constructSpecializedType(type, collectionClass); } // Copied almost verbatim from "createCollectionDeserializer" -- should try to share more code @Override public JsonDeserializer<?> createCollectionLikeDeserializer(DeserializationContext ctxt, CollectionLikeType type, final BeanDescription beanDesc) throws JsonMappingException

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> { JavaType contentType = type.getContentType(); // Very first thing: is deserializer hard-coded for elements? JsonDeserializer<Object> contentDeser = contentType.getValueHandler(); final DeserializationConfig config = ctxt.getConfig(); // Then optional type info (1.5): if type has been resolved, we may already know type deserializer: TypeDeserializer contentTypeDeser = contentType.getTypeHandler(); // but if not, may still be possible to find: if (contentTypeDeser == null) { contentTypeDeser = findTypeDeserializer(config, contentType); } JsonDeserializer<?> deser = _findCustomCollectionLikeDeserializer(type, config, beanDesc, contentTypeDeser, contentDeser); if (deser != null) { // and then new with 2.2: ability to post-process it too (Issue#120) if (_factoryConfig.hasDeserializerModifiers()) { for (BeanDeserializerModifier mod : _factoryConfig.deserializerModifiers()) { deser = mod.modifyCollectionLikeDeserializer(config, type, beanDesc, deser); } } } return deser; } /* /********************************************************** /* JsonDeserializerFactory impl: Map(-like) deserializers /********************************************************** */ @Override public JsonDeserializer<?> createMapDeserializer(DeserializationContext ctxt, MapType type, BeanDescription beanDesc) throws JsonMappingException { final DeserializationConfig config = ctxt.getConfig(); JavaType keyType = type.getKeyType(); JavaType contentType = type.getContentType(); // First: is there annotation-specified deserializer for values? @SuppressWarnings("unchecked") JsonDeserializer<Object> contentDeser = (JsonDeserializer<Object>) contentType.getValueHandler(); // Ok: need a key deserializer (null indicates 'default' here) KeyDeserializer keyDes = (KeyDeserializer) keyType.getValueHandler(); // Then optional type info (1.5); either attached to type, or resolved separately: TypeDeserializer contentTypeDeser = contentType.getTypeHandler(); // but if not, may still be possible to find: if (contentTypeDeser == null) { contentTypeDeser = findTypeDeserializer(config, contentType); } // 23-Nov-2010, tatu: Custom deserializer? JsonDeserializer<?> deser

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>Ignore(beanDesc.getClassInfo())); deser = md; } } } // and then new with 2.2: ability to post-process it too (Issue#120) if (_factoryConfig.hasDeserializerModifiers()) { for (BeanDeserializerModifier mod : _factoryConfig.deserializerModifiers()) { deser = mod.modifyMapDeserializer(config, type, beanDesc, deser); } } return deser; } // Copied almost verbatim from "createMapDeserializer" -- should try to share more code @Override public JsonDeserializer<?> createMapLikeDeserializer(DeserializationContext ctxt, MapLikeType type, final BeanDescription beanDesc) throws JsonMappingException { JavaType keyType = type.getKeyType(); JavaType contentType = type.getContentType(); final DeserializationConfig config = ctxt.getConfig(); // First: is there annotation-specified deserializer for values? @SuppressWarnings("unchecked") JsonDeserializer<Object> contentDeser = (JsonDeserializer<Object>) contentType.getValueHandler(); // Ok: need a key deserializer (null indicates 'default' here) KeyDeserializer keyDes = (KeyDeserializer) keyType.getValueHandler(); /* !!! 24-Jan-2012, tatu: NOTE: impls MUST use resolve() to find key deserializer! if (keyDes == null) { keyDes = p.findKeyDeserializer(config, keyType, property); } */ // Then optional type info (1.5); either attached to type, or resolve separately: TypeDeserializer contentTypeDeser = contentType.getTypeHandler(); // but if not, may still be possible to find: if (contentTypeDeser == null) { contentTypeDeser = findTypeDeserializer(config, contentType); } JsonDeserializer<?> deser = _findCustomMapLikeDeserializer(type, config, beanDesc, keyDes, contentTypeDeser, contentDeser); if (deser != null) { // and then new with 2.2: ability to post-process it too (Issue#120) if (_factoryConfig.hasDeserializerModifiers()) { for (BeanDeserializerModifier mod : _factoryConfig.deserializerModifiers()) { deser = mod.modifyMapLikeDeserializer(config, type, beanDesc, deser); }

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> } } return deser; } /* /********************************************************** /* JsonDeserializerFactory impl: Enum deserializers /********************************************************** */ /** * Factory method for constructing serializers of {@link Enum} types. */ @Override public JsonDeserializer<?> createEnumDeserializer(DeserializationContext ctxt, JavaType type, BeanDescription beanDesc) throws JsonMappingException { final DeserializationConfig config = ctxt.getConfig(); final Class<?> enumClass = type.getRawClass(); // 23-Nov-2010, tatu: Custom deserializer? JsonDeserializer<?> deser = _findCustomEnumDeserializer(enumClass, config, beanDesc); if (deser == null) { // [JACKSON-193] May have @JsonCreator for static factory method: for (AnnotatedMethod factory : beanDesc.getFactoryMethods()) { if (ctxt.getAnnotationIntrospector().hasCreatorAnnotation(factory)) { int argCount = factory.getParameterCount(); if (argCount == 1) { Class<?> returnType = factory.getRawReturnType(); // usually should be class, but may be just plain Enum<?> (for Enum.valueOf()?) if (returnType.isAssignableFrom(enumClass)) { deser = EnumDeserializer.deserializerForCreator(config, enumClass, factory); break; } } throw new IllegalArgumentException("Unsuitable method ("+factory+") decorated with @JsonCreator (for Enum type " +enumClass.getName()+")"); } } // [JACKSON-749] Also, need to consider @JsonValue, if one found if (deser == null) { deser = new EnumDeserializer(constructEnumResolver(enumClass, config, beanDesc.findJsonValueMethod())); } } // and then new with 2.2: ability to post-process it too (Issue#120) if (_factoryConfig.hasDeserializerModifiers()) { for (BeanDeserializerModifier mod : _factoryConfig.deserializerModifiers()) { deser = mod.modifyEnumDeserializer(config, type, beanDesc, deser); } } return deser; } /* /********************************************************** /* JsonDeserializerFactory impl: Tree deserializers /********************************************************** */ @Override public JsonDeserializer<?> createTreeDeserializer(DeserializationConfig config,

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> JavaType nodeType, BeanDescription beanDesc) throws JsonMappingException { @SuppressWarnings("unchecked") Class<? extends JsonNode> nodeClass = (Class<? extends JsonNode>) nodeType.getRawClass(); // 23-Nov-2010, tatu: Custom deserializer? JsonDeserializer<?> custom = _findCustomTreeNodeDeserializer(nodeClass, config, beanDesc); if (custom != null) { return custom; } return JsonNodeDeserializer.getDeserializer(nodeClass); } /* /********************************************************** /* JsonDeserializerFactory impl (partial): type deserializers /********************************************************** */ @Override public TypeDeserializer findTypeDeserializer(DeserializationConfig config, JavaType baseType) throws JsonMappingException { BeanDescription bean = config.introspectClassAnnotations(baseType.getRawClass()); AnnotatedClass ac = bean.getClassInfo(); AnnotationIntrospector ai = config.getAnnotationIntrospector(); TypeResolverBuilder<?> b = ai.findTypeResolver(config, ac, baseType); /* Ok: if there is no explicit type info handler, we may want to * use a default. If so, config object knows what to use. */ Collection<NamedType> subtypes = null; if (b == null) { b = config.getDefaultTyper(baseType); if (b == null) { return null; } } else { subtypes = config.getSubtypeResolver().collectAndResolveSubtypes(ac, config, ai); } // [JACKSON-505]: May need to figure out default implementation, if none found yet // (note: check for abstract type is not 100% mandatory, more of an optimization) if ((b.getDefaultImpl() == null) && baseType.isAbstract()) { JavaType defaultType = mapAbstractType(config, baseType); if (defaultType != null && defaultType.getRawClass() != baseType.getRawClass()) { b = b.defaultImpl(defaultType.getRawClass()); } } return b.buildTypeDeserializer(config, baseType, subtypes); } /** * Overridable method called after checking all other types. * * @since 2.2 */ protected JsonDeserializer<?> findOptionalStdDeserializer

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>(DeserializationContext ctxt, JavaType type, BeanDescription beanDesc) throws JsonMappingException { return OptionalHandlerFactory.instance.findDeserializer(type, ctxt.getConfig(), beanDesc); } /* /********************************************************** /* JsonDeserializerFactory impl (partial): key deserializers /********************************************************** */ @Override public KeyDeserializer createKeyDeserializer(DeserializationContext ctxt, JavaType type) throws JsonMappingException { final DeserializationConfig config = ctxt.getConfig(); KeyDeserializer deser = null; if (_factoryConfig.hasKeyDeserializers()) { BeanDescription beanDesc = config.introspectClassAnnotations(type.getRawClass()); for (KeyDeserializers d : _factoryConfig.keyDeserializers()) { deser = d.findKeyDeserializer(type, config, beanDesc); if (deser != null) { break; } } } // the only non-standard thing is this: if (deser == null) { if (type.isEnumType()) { return _createEnumKeyDeserializer(ctxt, type); } deser = StdKeyDeserializers.findStringBasedKeyDeserializer(config, type); } // and then new with 2.2: ability to post-process it too (Issue#120) if (deser != null) { if (_factoryConfig.hasDeserializerModifiers()) { for (BeanDeserializerModifier mod : _factoryConfig.deserializerModifiers()) { deser = mod.modifyKeyDeserializer(config, type, deser); } } } return deser; } private KeyDeserializer _createEnumKeyDeserializer(DeserializationContext ctxt, JavaType type) throws JsonMappingException { final DeserializationConfig config = ctxt.getConfig(); BeanDescription beanDesc = config.introspect(type); JsonDeserializer<?> des = findDeserializerFromAnnotation(ctxt, beanDesc.getClassInfo()); if (des != null) { return StdKeyDeserializers.constructDelegatingKeyDeserializer(config, type, des); } Class<?> enumClass = type.getRawClass(); // 23-Nov-2010, tatu: Custom deserializer? JsonDeserializer<?> custom = _findCustomEnumDeserializer(enumClass, config, beanDesc); if (custom != null) { return StdKeyDeserial

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>(DeserializationConfig config, JavaType baseType, AnnotatedMember annotated) throws JsonMappingException { AnnotationIntrospector ai = config.getAnnotationIntrospector(); TypeResolverBuilder<?> b = ai.findPropertyTypeResolver(config, annotated, baseType); // Defaulting: if no annotations on member, check value class if (b == null) { return findTypeDeserializer(config, baseType); } // but if annotations found, may need to resolve subtypes: Collection<NamedType> subtypes = config.getSubtypeResolver().collectAndResolveSubtypes( annotated, config, ai, baseType); return b.buildTypeDeserializer(config, baseType, subtypes); } /** * Method called to find and create a type information deserializer for values of * given container (list, array, map) property, if one is needed. * If not needed (no polymorphic handling configured for property), should return null. *<p> * Note that this method is only called for container bean properties, * and not for values in container types or root values (or non-container properties) * * @param containerType Type of property; must be a container type * @param propertyEntity Field or method that contains container property */ public TypeDeserializer findPropertyContentTypeDeserializer(DeserializationConfig config, JavaType containerType, AnnotatedMember propertyEntity) throws JsonMappingException { AnnotationIntrospector ai = config.getAnnotationIntrospector(); TypeResolverBuilder<?> b = ai.findPropertyContentTypeResolver(config, propertyEntity, containerType); JavaType contentType = containerType.getContentType(); // Defaulting: if no annotations on member, check class if (b == null) { return findTypeDeserializer(config, contentType); } // but if annotations found, may need to resolve subtypes: Collection<NamedType> subtypes = config.getSubtypeResolver().collectAndResolveSubtypes( propertyEntity, config, ai, contentType); return b.buildTypeDeserializer(config, contentType, subtypes); } /** * Helper method called to find one of default serializers for "well-known" * platform types: JDK-provided types, and small number of public Jackson * API types. * * @since 2.2 */ public Json

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>Deserializer<?> findDefaultDeserializer(DeserializationContext ctxt, JavaType type, BeanDescription beanDesc) throws JsonMappingException { Class<?> rawType = type.getRawClass(); // Object ("untyped"), String equivalents: if (rawType == CLASS_OBJECT) { return new UntypedObjectDeserializer(); } if (rawType == CLASS_STRING || rawType == CLASS_CHAR_BUFFER) { return StringDeserializer.instance; } if (rawType == CLASS_ITERABLE) { // [Issue#199]: Can and should 'upgrade' to a Collection type: TypeFactory tf = ctxt.getTypeFactory(); JavaType[] tps = tf.findTypeParameters(type, CLASS_ITERABLE); JavaType elemType = (tps == null || tps.length != 1) ? TypeFactory.unknownType() : tps[0]; CollectionType ct = tf.constructCollectionType(Collection.class, elemType); // Should we re-introspect beanDesc? For now let's not... return createCollectionDeserializer(ctxt, ct, beanDesc); } if (rawType == CLASS_MAP_ENTRY) { final DeserializationConfig config = ctxt.getConfig(); TypeFactory tf = ctxt.getTypeFactory(); JavaType[] tps = tf.findTypeParameters(type, CLASS_MAP_ENTRY); JavaType kt, vt; if (tps == null || tps.length != 2) { kt = vt = TypeFactory.unknownType(); } else { kt = tps[0]; vt = tps[1]; } TypeDeserializer vts = (TypeDeserializer) vt.getTypeHandler(); if (vts == null) { vts = findTypeDeserializer(config, vt); } JsonDeserializer<Object> valueDeser = vt.getValueHandler(); KeyDeserializer keyDes = (KeyDeserializer) kt.getValueHandler(); return new MapEntryDeserializer(type, keyDes, valueDeser, vts); } String clsName = rawType.getName(); if (rawType.isPrimitive() || clsName.startsWith("java.")) { // Primitives/wrappers, other Numbers: JsonDeserializer<?> deser = NumberDeserializers.find(rawType, clsName); if (deser == null) {

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> deser = DateDeserializers.find(rawType, clsName); } if (deser != null) { return deser; } } // and a few Jackson types as well: if (rawType == TokenBuffer.class) { return new TokenBufferDeserializer(); } if (AtomicReference.class.isAssignableFrom(rawType)) { // Must find parameterization TypeFactory tf = ctxt.getTypeFactory(); JavaType[] params = tf.findTypeParameters(type, AtomicReference.class); JavaType referencedType; if (params == null || params.length < 1) { // untyped (raw) referencedType = TypeFactory.unknownType(); } else { referencedType = params[0]; } TypeDeserializer vts = findTypeDeserializer(ctxt.getConfig(), referencedType); BeanDescription refdDesc = ctxt.getConfig().introspectClassAnnotations(referencedType); JsonDeserializer<?> deser = findDeserializerFromAnnotation(ctxt, refdDesc.getClassInfo()); return new AtomicReferenceDeserializer(referencedType, vts, deser); } JsonDeserializer<?> deser = findOptionalStdDeserializer(ctxt, type, beanDesc); if (deser != null) { return deser; } return JdkDeserializers.find(rawType, clsName); } /* /********************************************************** /* Helper methods, finding custom deserializers /********************************************************** */ protected JsonDeserializer<?> _findCustomArrayDeserializer(ArrayType type, DeserializationConfig config, BeanDescription beanDesc, TypeDeserializer elementTypeDeserializer, JsonDeserializer<?> elementDeserializer) throws JsonMappingException { for (Deserializers d : _factoryConfig.deserializers()) { JsonDeserializer<?> deser = d.findArrayDeserializer(type, config, beanDesc, elementTypeDeserializer, elementDeserializer); if (deser != null) { return deser; } } return null; } @SuppressWarnings("unchecked") protected JsonDeserializer<Object> _findCustomBeanDeserializer(JavaType type, DeserializationConfig config, BeanDescription beanDesc) throws JsonMappingException { for (Deserializers d : _factoryConfig.deserializers()) { JsonDeserializer<?> deser = d.findBeanDeserializer(type, config, beanDesc); if (deser != null) { return (Json

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>Deserializer<Object>) deser; } } return null; } protected JsonDeserializer<?> _findCustomCollectionDeserializer(CollectionType type, DeserializationConfig config, BeanDescription beanDesc, TypeDeserializer elementTypeDeserializer, JsonDeserializer<?> elementDeserializer) throws JsonMappingException { for (Deserializers d : _factoryConfig.deserializers()) { JsonDeserializer<?> deser = d.findCollectionDeserializer(type, config, beanDesc, elementTypeDeserializer, elementDeserializer); if (deser != null) { return deser; } } return null; } protected JsonDeserializer<?> _findCustomCollectionLikeDeserializer(CollectionLikeType type, DeserializationConfig config, BeanDescription beanDesc, TypeDeserializer elementTypeDeserializer, JsonDeserializer<?> elementDeserializer) throws JsonMappingException { for (Deserializers d : _factoryConfig.deserializers()) { JsonDeserializer<?> deser = d.findCollectionLikeDeserializer(type, config, beanDesc, elementTypeDeserializer, elementDeserializer); if (deser != null) { return deser; } } return null; } protected JsonDeserializer<?> _findCustomEnumDeserializer(Class<?> type, DeserializationConfig config, BeanDescription beanDesc) throws JsonMappingException { for (Deserializers d : _factoryConfig.deserializers()) { JsonDeserializer<?> deser = d.findEnumDeserializer(type, config, beanDesc); if (deser != null) { return deser; } } return null; } protected JsonDeserializer<?> _findCustomMapDeserializer(MapType type, DeserializationConfig config, BeanDescription beanDesc, KeyDeserializer keyDeserializer, TypeDeserializer elementTypeDeserializer, JsonDeserializer<?> elementDeserializer) throws JsonMappingException { for (Deserializers d : _factoryConfig.deserializers()) { JsonDeserializer<?> deser = d.findMapDeserializer(type, config, beanDesc, keyDeserializer, elementTypeDeserializer, elementDeserializer); if (deser != null) { return deser; } } return null; } protected JsonDeserializer<?> _findCustomMapLikeDeserializer(MapLikeType type, DeserializationConfig config, BeanDescription beanDesc, KeyDeserializer keyDeserializer, TypeDeserializer elementTypeDeserializer, JsonDeserializer<?> elementDeserializer) throws JsonMappingException {

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> for (Deserializers d : _factoryConfig.deserializers()) { JsonDeserializer<?> deser = d.findMapLikeDeserializer(type, config, beanDesc, keyDeserializer, elementTypeDeserializer, elementDeserializer); if (deser != null) { return deser; } } return null; } protected JsonDeserializer<?> _findCustomTreeNodeDeserializer(Class<? extends JsonNode> type, DeserializationConfig config, BeanDescription beanDesc) throws JsonMappingException { for (Deserializers d : _factoryConfig.deserializers()) { JsonDeserializer<?> deser = d.findTreeNodeDeserializer(type, config, beanDesc); if (deser != null) { return deser; } } return null; } /* /********************************************************** /* Helper methods, value/content/key type introspection /********************************************************** */ /** * Helper method called to check if a class or method * has annotation that tells which class to use for deserialization. * Returns null if no such annotation found. */ protected JsonDeserializer<Object> findDeserializerFromAnnotation(DeserializationContext ctxt, Annotated ann) throws JsonMappingException { Object deserDef = ctxt.getAnnotationIntrospector().findDeserializer(ann); if (deserDef == null) { return null; } return ctxt.deserializerInstance(ann, deserDef); } /** * Method called to see if given method has annotations that indicate * a more specific type than what the argument specifies. * If annotations are present, they must specify compatible Class; * instance of which can be assigned using the method. This means * that the Class has to be raw class of type, or its sub-class * (or, implementing class if original Class instance is an interface). * * @param a Method or field that the type is associated with * @param type Type of field, or the setter argument * * @return Original type if no annotations are present; or a more * specific type derived from it if type annotation(s) was found * * @throws JsonMappingException if invalid annotation is found */ @SuppressWarnings({ "unchecked" }) protected <T extends JavaType> T modifyTypeByAnnotation(DeserializationContext ctxt, Annotated a, T type) throws JsonMappingException

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> { // first: let's check class for the instance itself: AnnotationIntrospector intr = ctxt.getAnnotationIntrospector(); Class<?> subclass = intr.findDeserializationType(a, type); if (subclass != null) { try { type = (T) type.narrowBy(subclass); } catch (IllegalArgumentException iae) { throw new JsonMappingException("Failed to narrow type "+type+" with concrete-type annotation (value "+subclass.getName()+"), method '"+a.getName()+"': "+iae.getMessage(), null, iae); } } // then key class if (type.isContainerType()) { Class<?> keyClass = intr.findDeserializationKeyType(a, type.getKeyType()); if (keyClass != null) { // illegal to use on non-Maps if (!(type instanceof MapLikeType)) { throw new JsonMappingException("Illegal key-type annotation: type "+type+" is not a Map(-like) type"); } try { type = (T) ((MapLikeType) type).narrowKey(keyClass); } catch (IllegalArgumentException iae) { throw new JsonMappingException("Failed to narrow key type "+type+" with key-type annotation ("+keyClass.getName()+"): "+iae.getMessage(), null, iae); } } JavaType keyType = type.getKeyType(); /* 21-Mar-2011, tatu: ... and associated deserializer too (unless already assigned) * (not 100% why or how, but this does seem to get called more than once, which * is not good: for now, let's just avoid errors) */ if (keyType != null && keyType.getValueHandler() == null) { Object kdDef = intr.findKeyDeserializer(a); KeyDeserializer kd = ctxt.keyDeserializerInstance(a, kdDef); if (kd != null) { type = (T) ((MapLikeType) type).withKeyValueHandler(kd); keyType = type.getKeyType(); // just in case it's used below } } // and finally content class; only applicable to structured types Class<?> cc = intr.findDeserializationContentType(a, type.getContentType()); if (cc != null)

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> { try { type = (T) type.narrowContentsBy(cc); } catch (IllegalArgumentException iae) { throw new JsonMappingException("Failed to narrow content type "+type+" with content-type annotation ("+cc.getName()+"): "+iae.getMessage(), null, iae); } } // ... as well as deserializer for contents: JavaType contentType = type.getContentType(); if (contentType.getValueHandler() == null) { // as with above, avoid resetting (which would trigger exception) Object cdDef = intr.findContentDeserializer(a); JsonDeserializer<?> cd = ctxt.deserializerInstance(a, cdDef); if (cd != null) { type = (T) type.withContentValueHandler(cd); } } } return type; } /** * Helper method used to resolve method return types and field * types. The main trick here is that the containing bean may * have type variable binding information (when deserializing * using generic type passed as type reference), which is * needed in some cases. */ protected JavaType resolveType(DeserializationContext ctxt, BeanDescription beanDesc, JavaType type, AnnotatedMember member) throws JsonMappingException { // [JACKSON-154]: Also need to handle keyUsing, contentUsing if (type.isContainerType()) { AnnotationIntrospector intr = ctxt.getAnnotationIntrospector(); JavaType keyType = type.getKeyType(); if (keyType != null) { Object kdDef = intr.findKeyDeserializer(member); KeyDeserializer kd = ctxt.keyDeserializerInstance(member, kdDef); if (kd != null) { type = ((MapLikeType) type).withKeyValueHandler(kd); keyType = type.getKeyType(); // just in case it's used below } } // and all container types have content types... Object cdDef = intr.findContentDeserializer(member); JsonDeserializer<?> cd = ctxt.deserializerInstance(member, cdDef); if (cd != null) { type = type.withContentValueHandler(cd); } /* 04-Feb-2010, tatu: Need to figure out JAXB annotations that indicate type * information to use for

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> /** * Convenience method for creating a new factory instance with additional deserializer * provider. */ public abstract DeserializerFactory withAdditionalDeserializers(Deserializers additional); /** * Convenience method for creating a new factory instance with additional * {@link KeyDeserializers}. */ public abstract DeserializerFactory withAdditionalKeyDeserializers(KeyDeserializers additional); /** * Convenience method for creating a new factory instance with additional * {@link BeanDeserializerModifier}. */ public abstract DeserializerFactory withDeserializerModifier(BeanDeserializerModifier modifier); /** * Convenience method for creating a new factory instance with additional * {@link AbstractTypeResolver}. */ public abstract DeserializerFactory withAbstractTypeResolver(AbstractTypeResolver resolver); /** * Convenience method for creating a new factory instance with additional * {@link ValueInstantiators}. */ public abstract DeserializerFactory withValueInstantiators(ValueInstantiators instantiators); /* /********************************************************** /* Basic DeserializerFactory API: /********************************************************** */ /** * Method that can be called to try to resolve an abstract type * (interface, abstract class) into a concrete type, or at least * something "more concrete" (abstract class instead of interface). * Will either return passed type, or a more specific type. */ public abstract JavaType mapAbstractType(DeserializationConfig config, JavaType type) throws JsonMappingException; /** * Method that is to find all creators (constructors, factory methods) * for the bean type to deserialize. */ public abstract ValueInstantiator findValueInstantiator(DeserializationContext ctxt, BeanDescription beanDesc) throws JsonMappingException; /** * Method called to create (or, for completely immutable deserializers, * reuse) a deserializer that can convert JSON content into values of * specified Java "bean" (POJO) type. * At this point it is known that the type is not otherwise recognized * as one of structured types (array, Collection, Map) or a well-known * JDK type (enum, primitives/wrappers, String); this method only * gets called if other options are exhausted. This also means that * this method can be overridden to add support for custom types. * * @param type Type to be deserialized */ public abstract JsonDeserializer<Object> createBeanDeserializer(Deserialization

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>Context ctxt, JavaType type, BeanDescription beanDesc) throws JsonMappingException; /** * Method called to create a deserializer that will use specified Builder * class for building value instances. * * @since 2.0 */ public abstract JsonDeserializer<Object> createBuilderBasedDeserializer( DeserializationContext ctxt, JavaType type, BeanDescription beanDesc, Class<?> builderClass) throws JsonMappingException; /** * Method called to create (or, for completely immutable deserializers, * reuse) a deserializer that can convert JSON content into values of * specified Java type. * * @param type Type to be deserialized */ public abstract JsonDeserializer<?> createArrayDeserializer(DeserializationContext ctxt, ArrayType type, BeanDescription beanDesc) throws JsonMappingException; public abstract JsonDeserializer<?> createCollectionDeserializer(DeserializationContext ctxt, CollectionType type, BeanDescription beanDesc) throws JsonMappingException; public abstract JsonDeserializer<?> createCollectionLikeDeserializer(DeserializationContext ctxt, CollectionLikeType type, BeanDescription beanDesc) throws JsonMappingException; public abstract JsonDeserializer<?> createEnumDeserializer(DeserializationContext ctxt, JavaType type, BeanDescription beanDesc) throws JsonMappingException; public abstract JsonDeserializer<?> createMapDeserializer(DeserializationContext ctxt, MapType type, BeanDescription beanDesc) throws JsonMappingException; public abstract JsonDeserializer<?> createMapLikeDeserializer(DeserializationContext ctxt, MapLikeType type, BeanDescription beanDesc) throws JsonMappingException; /** * Method called to create and return a deserializer that can construct * JsonNode(s) from JSON content. */ public abstract JsonDeserializer<?> createTreeDeserializer(DeserializationConfig config, JavaType type, BeanDescription beanDesc) throws JsonMappingException; /** * Method called to find if factory knows how to create a key deserializer * for specified type; currently this means checking if a module has registered * possible deserializers. * * @return Key deserializer to use for specified type, if one found; null if not * (and default key deserializer should be used) */ public abstract KeyDeserializer createKeyDeserializer(DeserializationContext ctxt, JavaType type) throws JsonMappingException; /** * Method called to find and create a type information deserializer for given base type,

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> * if one is needed. If not needed (no polymorphic handling configured for type), * should return null. *<p> * Note that this method is usually only directly called for values of container (Collection, * array, Map) types and root values, but not for bean property values. * * @param baseType Declared base type of the value to deserializer (actual * deserializer type will be this type or its subtype) * * @return Type deserializer to use for given base type, if one is needed; null if not. */ public abstract TypeDeserializer findTypeDeserializer(DeserializationConfig config, JavaType baseType) throws JsonMappingException; }

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>package com.fasterxml.jackson.databind.ser.std; import java.io.IOException; import java.lang.reflect.Type; import com.fasterxml.jackson.core.*; import com.fasterxml.jackson.databind.JavaType; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.annotation.JacksonStdImpl; import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitorWrapper; /** * This is the special serializer for regular {@link java.lang.String}s. *<p> * Since this is one of "native" types, no type information is ever * included on serialization (unlike for most scalar types as of 1.5) */ @JacksonStdImpl public final class StringSerializer extends NonTypedScalarSerializerBase<String> { private static final long serialVersionUID = 1L; public StringSerializer() { super(String.class); } /** * For Strings, both null and Empty String qualify for emptiness. */ @Override @Deprecated public boolean isEmpty(String value) { return (value == null) || (value.length() == 0); } @Override public boolean isEmpty(SerializerProvider prov, String value) { return (value == null) || (value.length() == 0); } @Override public void serialize(String value, JsonGenerator jgen, SerializerProvider provider) throws IOException { jgen.writeString(value); } @Override public JsonNode getSchema(SerializerProvider provider, Type typeHint) { return createSchemaNode("string", true); } @Override public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) throws JsonMappingException { if (visitor != null) visitor.expectStringFormat(typeHint); } }

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> _elementTypeDeserializer)) { return this; } return new ObjectArrayDeserializer(_arrayType, (JsonDeserializer<Object>) elemDeser, elemTypeDeser); } @Override public JsonDeserializer<?> createContextual(DeserializationContext ctxt, BeanProperty property) throws JsonMappingException { JsonDeserializer<?> deser = _elementDeserializer; // #125: May have a content converter deser = findConvertingContentDeserializer(ctxt, property, deser); final JavaType vt = _arrayType.getContentType(); if (deser == null) { deser = ctxt.findContextualValueDeserializer(vt, property); } else { // if directly assigned, probably not yet contextual, so: deser = ctxt.handleSecondaryContextualization(deser, property, vt); } TypeDeserializer elemTypeDeser = _elementTypeDeserializer; if (elemTypeDeser != null) { elemTypeDeser = elemTypeDeser.forProperty(property); } return withDeserializer(elemTypeDeser, deser); } @Override // since 2.5 public boolean isCachable() { // Important: do NOT cache if polymorphic values, or ones with custom deserializer return (_elementDeserializer == null) && (_elementTypeDeserializer == null); } /* /********************************************************** /* ContainerDeserializerBase API /********************************************************** */ @Override public JavaType getContentType() { return _arrayType.getContentType(); } @Override public JsonDeserializer<Object> getContentDeserializer() { return _elementDeserializer; } /* /********************************************************** /* JsonDeserializer API /********************************************************** */ @Override public Object[] deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { // Ok: must point to START_ARRAY (or equivalent) if (!jp.isExpectedStartArrayToken()) { return handleNonArray(jp, ctxt); } final ObjectBuffer buffer = ctxt.leaseObjectBuffer(); Object[] chunk = buffer.resetAndStart(); int ix = 0; JsonToken t; final TypeDeserializer typeDeser = _elementTypeDeserializer; try { while ((t = jp.nextToken()) != JsonToken.END_ARRAY) { // Note: must handle null explicitly here; value

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> deserializers won't Object value; if (t == JsonToken.VALUE_NULL) { value = _elementDeserializer.getNullValue(); } else if (typeDeser == null) { value = _elementDeserializer.deserialize(jp, ctxt); } else { value = _elementDeserializer.deserializeWithType(jp, ctxt, typeDeser); } if (ix >= chunk.length) { chunk = buffer.appendCompletedChunk(chunk); ix = 0; } chunk[ix++] = value; } } catch (Exception e) { throw JsonMappingException.wrapWithPath(e, chunk, buffer.bufferedSize() + ix); } Object[] result; if (_untyped) { result = buffer.completeAndClearBuffer(chunk, ix); } else { result = buffer.completeAndClearBuffer(chunk, ix, _elementClass); } ctxt.returnObjectBuffer(buffer); return result; } @Override public Object[] deserializeWithType(JsonParser jp, DeserializationContext ctxt, TypeDeserializer typeDeserializer) throws IOException, JsonProcessingException { /* Should there be separate handling for base64 stuff? * for now this should be enough: */ return (Object[]) typeDeserializer.deserializeTypedFromArray(jp, ctxt); } /* /********************************************************** /* Internal methods /********************************************************** */ protected Byte[] deserializeFromBase64(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { // First same as what PrimitiveArrayDeserializers.ByteDeser does: byte[] b = jp.getBinaryValue(ctxt.getBase64Variant()); // But then need to convert to wrappers Byte[] result = new Byte[b.length]; for (int i = 0, len = b.length; i < len; ++i) { result[i] = Byte.valueOf(b[i]); } return result; } private final Object[] handleNonArray(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { // [JACKSON-620] Empty String can become null... if ((jp.getCurrentToken() == JsonToken.VALUE_STRING) && ctxt.isEnabled(DeserializationFeature.ACCEPT_EMPTY

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>package com.fasterxml.jackson.databind.deser; import com.fasterxml.jackson.databind.*; /** * Add-on interface that {@link JsonDeserializer}s can implement to get a callback * that can be used to create contextual (context-dependent) instances of * deserializer to use for handling properties of supported type. * This can be useful * for deserializers that can be configured by annotations, or should otherwise * have differing behavior depending on what kind of property is being deserialized. *<p> * Note that in cases where deserializer needs both contextualization and * resolution -- that is, implements both this interface and {@link ResolvableDeserializer} * -- resolution via {@link ResolvableDeserializer} occurs first, and contextual * resolution (via this interface) later on. */ public interface ContextualDeserializer { /** * Method called to see if a different (or differently configured) deserializer * is needed to deserialize values of specified property. * Note that instance that this method is called on is typically shared one and * as a result method should <b>NOT</b> modify this instance but rather construct * and return a new instance. This instance should only be returned as-is, in case * it is already suitable for use. * * @param ctxt Deserialization context to access configuration, additional * deserializers that may be needed by this deserializer * @param property Method, field or constructor parameter that represents the property * (and is used to assign deserialized value). * Should be available; but there may be cases where caller can not provide it and * null is passed instead (in which case impls usually pass 'this' deserializer as is) * * @return Deserializer to use for deserializing values of specified property; * may be this instance or a new instance. * * @throws JsonMappingException */ public JsonDeserializer<?> createContextual(DeserializationContext ctxt, BeanProperty property) throws JsonMappingException; }

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>package com.fasterxml.jackson.databind.deser.impl; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.databind.DeserializationContext; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.deser.std.StdDeserializer; /** * Special bogus "serializer" that will throw * {@link JsonMappingException} if an attempt is made to deserialize * a value. This is used as placeholder to avoid NPEs for uninitialized * structured serializers or handlers. */ public class FailingDeserializer extends StdDeserializer<Object> { private static final long serialVersionUID = 1L; protected final String _message; public FailingDeserializer(String m) { super(Object.class); _message = m; } @Override public Object deserialize(JsonParser jp, DeserializationContext ctxt) throws JsonMappingException{ throw ctxt.mappingException(_message); } }

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>ters) /********************************************************** */ /** * Method for adding a new property or replacing a property. */ public void addOrReplaceProperty(SettableBeanProperty prop, boolean allowOverride) { _properties.put(prop.getName(), prop); } /** * Method to add a property setter. Will ensure that there is no * unexpected override; if one is found will throw a * {@link IllegalArgumentException}. */ public void addProperty(SettableBeanProperty prop) { SettableBeanProperty old = _properties.put(prop.getName(), prop); if (old != null && old != prop) { // should never occur... throw new IllegalArgumentException("Duplicate property '"+prop.getName()+"' for "+_beanDesc.getType()); } } /** * Method called to add a property that represents so-called back reference; * reference that "points back" to object that has forward reference to * currently built bean. */ public void addBackReferenceProperty(String referenceName, SettableBeanProperty prop) { if (_backRefProperties == null) { _backRefProperties = new HashMap<String, SettableBeanProperty>(4); } _backRefProperties.put(referenceName, prop); // also: if we had property with same name, actually remove it if (_properties != null) { _properties.remove(prop.getName()); } // ??? 23-Jul-2012, tatu: Should it be included in list of all properties? // For now, won't add, since it is inferred, not explicit... } public void addInjectable(PropertyName propName, JavaType propType, Annotations contextAnnotations, AnnotatedMember member, Object valueId) { if (_injectables == null) { _injectables = new ArrayList<ValueInjector>(); } _injectables.add(new ValueInjector(propName, propType, contextAnnotations, member, valueId)); } /** * Method that will add property name as one of properties that can * be ignored if not recognized. */ public void addIgnorable(String propName) { if (_ignorableProps == null) { _ignorableProps = new HashSet<String>(); } _ignorableProps.

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>package com.fasterxml.jackson.databind.util; import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.cfg.MapperConfig; import com.fasterxml.jackson.databind.introspect.AnnotatedClass; import com.fasterxml.jackson.databind.type.ClassKey; /** * Helper class for caching resolved root names. */ public class RootNameLookup implements java.io.Serializable { private static final long serialVersionUID = 1L; /** * For efficient operation, let's try to minimize number of times we * need to introspect root element name to use. */ protected transient LRUMap<ClassKey,PropertyName> _rootNames; public RootNameLookup() { _rootNames = new LRUMap<ClassKey,PropertyName>(20, 200); } public PropertyName findRootName(JavaType rootType, MapperConfig<?> config) { return findRootName(rootType.getRawClass(), config); } public PropertyName findRootName(Class<?> rootType, MapperConfig<?> config) { ClassKey key = new ClassKey(rootType); PropertyName name = _rootNames.get(key); if (name != null) { return name; } BeanDescription beanDesc = config.introspectClassAnnotations(rootType); AnnotationIntrospector intr = config.getAnnotationIntrospector(); AnnotatedClass ac = beanDesc.getClassInfo(); name = intr.findRootName(ac); // No answer so far? Let's just default to using simple class name if (name == null || !name.hasSimpleName()) { // Should we strip out enclosing class tho? For now, nope: name = new PropertyName(rootType.getSimpleName()); } _rootNames.put(key, name); return name; } /* /********************************************************** /* Serializable overrides /********************************************************** */ /** * Need to override to reproduce cache object via constructor, instead * of serialize/deserialize (since we do NOT want to retain cached data) */ protected Object readResolve() { return new RootNameLookup(); } }

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>package com.fasterxml.jackson.databind.deser; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import com.fasterxml.jackson.core.JsonLocation; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.deser.impl.ReadableObjectId; /** * Exception thrown during deserialization when there are object id that can't * be resolved. * * @author pgelinas */ public final class UnresolvedForwardReference extends JsonMappingException { private static final long serialVersionUID = 1L; private ReadableObjectId _roid; private List<UnresolvedId> _unresolvedIds; public UnresolvedForwardReference(String msg, JsonLocation loc, ReadableObjectId roid) { super(msg, loc); _roid = roid; } public UnresolvedForwardReference(String msg) { super(msg); _unresolvedIds = new ArrayList<UnresolvedId>(); } // ****************************** // ****** Accessor methods ****** // ****************************** public ReadableObjectId getRoid() { return _roid; } public Object getUnresolvedId() { return _roid.getKey().key; } public void addUnresolvedId(Object id, Class<?> type, JsonLocation where) { _unresolvedIds.add(new UnresolvedId(id, type, where)); } public List<UnresolvedId> getUnresolvedIds(){ return _unresolvedIds; } @Override public String getMessage() { String msg = super.getMessage(); if (_unresolvedIds == null) { return msg; } StringBuilder sb = new StringBuilder(msg); Iterator<UnresolvedId> iterator = _unresolvedIds.iterator(); while (iterator.hasNext()) { UnresolvedId unresolvedId = iterator.next(); sb.append(unresolvedId.toString()); if (iterator.hasNext()) { sb.append(", "); } } sb.append('.'); return sb.toString(); } }

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>package com.fasterxml.jackson.databind.jsonschema; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.SerializerProvider; import java.lang.reflect.Type; /** * Marker interface for schema-aware serializers. */ public interface SchemaAware { /** * Get the representation of the schema to which this serializer will conform. * * @param provider The serializer provider. * @param typeHint A hint about the type. * @return <a href="http://json-schema.org/">Json-schema</a> for this serializer. */ public JsonNode getSchema(SerializerProvider provider, Type typeHint) throws JsonMappingException; /** * Get the representation of the schema to which this serializer will conform. * * @param provider The serializer provider. * @param isOptional Is the type optional * @param typeHint A hint about the type. * @return <a href="http://json-schema.org/">Json-schema</a> for this serializer. */ public JsonNode getSchema(SerializerProvider provider, Type typeHint, boolean isOptional) throws JsonMappingException; }

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>(value, jgen); serialize(value, jgen, provider); typeSer.writeTypeSuffixForScalar(value, jgen); } @Override public JsonNode getSchema(SerializerProvider provider, Type typeHint) { /* 01-Jan-2010, tatu: Not 100% sure what we should say here: * type is basically not known. This seems closest * approximation */ return createSchemaNode("any", true); } @Override public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) throws JsonMappingException { /* 01-Jan-2010, tatu: Not 100% sure what we should say here: * type is basically not known. This seems closest * approximation */ visitor.expectAnyFormat(typeHint); } }

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> occurs if and only if the "value method" was annotated with * {@link com.fasterxml.jackson.databind.annotation.JsonSerialize#using}), otherwise * null */ @SuppressWarnings("unchecked") public JsonValueSerializer(Method valueMethod, JsonSerializer<?> ser) { super(valueMethod.getReturnType(), false); _accessorMethod = valueMethod; _valueSerializer = (JsonSerializer<Object>) ser; _property = null; _forceTypeInformation = true; // gets reconsidered when we are contextualized } @SuppressWarnings("unchecked") public JsonValueSerializer(JsonValueSerializer src, BeanProperty property, JsonSerializer<?> ser, boolean forceTypeInfo) { super(_notNullClass(src.handledType())); _accessorMethod = src._accessorMethod; _valueSerializer = (JsonSerializer<Object>) ser; _property = property; _forceTypeInformation = forceTypeInfo; } @SuppressWarnings("unchecked") private final static Class<Object> _notNullClass(Class<?> cls) { return (cls == null) ? Object.class : (Class<Object>) cls; } public JsonValueSerializer withResolved(BeanProperty property, JsonSerializer<?> ser, boolean forceTypeInfo) { if (_property == property && _valueSerializer == ser && forceTypeInfo == _forceTypeInformation) { return this; } return new JsonValueSerializer(this, property, ser, forceTypeInfo); } /* /********************************************************** /* Post-processing /********************************************************** */ /** * We can try to find the actual serializer for value, if we can * statically figure out what the result type must be. */ @Override public JsonSerializer<?> createContextual(SerializerProvider provider, BeanProperty property) throws JsonMappingException { JsonSerializer<?> ser = _valueSerializer; if (ser == null) { /* Can only assign serializer statically if the declared type is final: * if not, we don't really know the actual type until we get the instance. */ // 10-Mar-2010, tatu: Except if static typing is to be used if (provider.isEnabled(MapperFeature.USE_STATIC_TYPING) || Modifier.isFinal(_accessorMethod.getReturnType().getModifiers())) { JavaType

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> type, to see infinite recursion... while (t instanceof InvocationTargetException && t.getCause() != null) { t = t.getCause(); } // Errors shouldn't be wrapped (and often can't, as well) if (t instanceof Error) { throw (Error) t; } // let's try to indicate the path best we can... throw JsonMappingException.wrapWithPath(t, bean, _accessorMethod.getName() + "()"); } } @Override public void serializeWithType(Object bean, JsonGenerator jgen, SerializerProvider provider, TypeSerializer typeSer0) throws IOException { // Regardless of other parts, first need to find value to serialize: Object value = null; try { value = _accessorMethod.invoke(bean); // and if we got null, can also just write it directly if (value == null) { provider.defaultSerializeNull(jgen); return; } JsonSerializer<Object> ser = _valueSerializer; if (ser == null) { // already got a serializer? fabulous, that be easy... // ser = provider.findTypedValueSerializer(value.getClass(), true, _property); ser = provider.findValueSerializer(value.getClass(), _property); } else { /* 09-Dec-2010, tatu: To work around natural type's refusal to add type info, we do * this (note: type is for the wrapper type, not enclosed value!) */ if (_forceTypeInformation) { typeSer0.writeTypePrefixForScalar(bean, jgen); ser.serialize(value, jgen, provider); typeSer0.writeTypeSuffixForScalar(bean, jgen); return; } } /* 13-Feb-2013, tatu: Turns out that work-around should NOT be required * at all; it would not lead to correct behavior (as per #167). */ // and then redirect type id lookups // TypeSerializer typeSer = new TypeSerializerWrapper(typeSer0, bean); ser.serializeWithType(value, jgen, provider, typeSer0); } catch (IOException ioe) { throw ioe; }

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> catch (Exception e) { Throwable t = e; // Need to unwrap this specific type, to see infinite recursion... while (t instanceof InvocationTargetException && t.getCause() != null) { t = t.getCause(); } // Errors shouldn't be wrapped (and often can't, as well) if (t instanceof Error) { throw (Error) t; } // let's try to indicate the path best we can... throw JsonMappingException.wrapWithPath(t, bean, _accessorMethod.getName() + "()"); } } @SuppressWarnings("deprecation") @Override public JsonNode getSchema(SerializerProvider provider, Type typeHint) throws JsonMappingException { if (_valueSerializer instanceof SchemaAware) { return ((SchemaAware)_valueSerializer).getSchema(provider, null); } return com.fasterxml.jackson.databind.jsonschema.JsonSchema.getDefaultSchemaNode(); } @Override public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) throws JsonMappingException { JsonSerializer<Object> ser = _valueSerializer; if (ser == null) { if (typeHint == null) { if (_property != null) { typeHint = _property.getType(); } if (typeHint == null) { typeHint = visitor.getProvider().constructType(_accessorMethod.getReturnType()); } } ser = visitor.getProvider().findTypedValueSerializer(typeHint, false, _property); if (ser == null) { visitor.expectAnyFormat(typeHint); return; } } ser.acceptJsonFormatVisitor(visitor, null); } protected boolean isNaturalTypeWithStdHandling(Class<?> rawType, JsonSerializer<?> ser) { // First: do we have a natural type being handled? if (rawType.isPrimitive()) { if (rawType != Integer.TYPE && rawType != Boolean.TYPE && rawType != Double.TYPE) { return false; } } else { if (rawType != String.class && rawType != Integer.class && rawType != Boolean.class && rawType != Double.class) { return false; } } return isDefaultSerializer(ser); } /* /**********************************************************

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> return _fromLongCreator.call1(Long.valueOf(value)); } } catch (Exception e) { throw wrapException(e); } catch (ExceptionInInitializerError e) { throw wrapException(e); } throw ctxt.mappingException("Can not instantiate value of type "+getValueTypeDesc() +" from Long integral number ("+value+"); no single-long-arg constructor/factory method"); } @Override public Object createFromDouble(DeserializationContext ctxt, double value) throws IOException { try { if (_fromDoubleCreator != null) { return _fromDoubleCreator.call1(Double.valueOf(value)); } } catch (Exception e) { throw wrapException(e); } catch (ExceptionInInitializerError e) { throw wrapException(e); } throw ctxt.mappingException("Can not instantiate value of type "+getValueTypeDesc() +" from Floating-point number ("+value+"); no one-double/Double-arg constructor/factory method"); } @Override public Object createFromBoolean(DeserializationContext ctxt, boolean value) throws IOException { try { if (_fromBooleanCreator != null) { return _fromBooleanCreator.call1(Boolean.valueOf(value)); } } catch (Exception e) { throw wrapException(e); } catch (ExceptionInInitializerError e) { throw wrapException(e); } throw ctxt.mappingException("Can not instantiate value of type "+getValueTypeDesc() +" from Boolean value ("+value+"); no single-boolean/Boolean-arg constructor/factory method"); } /* /********************************************************** /* Extended API: configuration mutators, accessors /********************************************************** */ @Override public AnnotatedWithParams getDelegateCreator() { return _delegateCreator; } @Override public AnnotatedWithParams getDefaultCreator() { return _defaultCreator; } @Override public AnnotatedWithParams getWithArgsCreator() { return _withArgsCreator; } @Override public AnnotatedParameter getIncompleteParameter() { return _incompleteParameter; } /* /********************************************************** /* Internal methods /********************************************************** */ protected JsonMappingException wrapException(Throwable t) { while (t.getCause() != null) {

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> t = t.getCause(); } if (t instanceof JsonMappingException) { return (JsonMappingException) t; } return new JsonMappingException("Instantiation of "+getValueTypeDesc()+" value failed: "+t.getMessage(), t); } }

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> * writer is associated with; usually this means annotations on enclosing class * for property. * * @since 2.5 */ public abstract <A extends Annotation> A getContextAnnotation(Class<A> acls); /* /********************************************************** /* Serialization methods, regular output /********************************************************** */ /** * The main serialization method called by filter when property is to be written normally. */ public abstract void serializeAsField(Object value, JsonGenerator jgen, SerializerProvider provider) throws Exception; /** * Serialization method that filter needs to call in cases where property is to be * filtered, but the underlying data format requires a placeholder of some kind. * This is usually the case for tabular (positional) data formats such as CSV. */ public abstract void serializeAsOmittedField(Object value, JsonGenerator jgen, SerializerProvider provider) throws Exception; /* /********************************************************** /* Serialization methods, explicit positional/tabular formats /********************************************************** */ /** * Serialization method called when output is to be done as an array, * that is, not using property names. This is needed when serializing * container ({@link java.util.Collection}, array) types, * or POJOs using <code>tabular</code> ("as array") output format. *<p> * Note that this mode of operation is independent of underlying * data format; so it is typically NOT called for fully tabular formats such as CSV, * where logical output is still as form of POJOs. */ public abstract void serializeAsElement(Object value, JsonGenerator jgen, SerializerProvider provider) throws Exception; /** * Serialization method called when doing tabular (positional) output from databind, * but then value is to be omitted. This requires output of a placeholder value * of some sort; often similar to {@link #serializeAsOmittedField}. */ public abstract void serializeAsPlaceholder(Object value, JsonGenerator jgen, SerializerProvider provider) throws Exception; /* /********************************************************** /* Schema-related /********************************************************** */ /** * Traversal method used for things like JSON Schema generation, or * POJO introspection. */ public abstract void depositSchemaProperty(JsonObjectFormatVisitor objectVisitor) throws JsonMappingException; /**

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> * Legacy method called for JSON Schema generation; should not be called by new code * * @deprecated Since 2.2 */ @Deprecated public abstract void depositSchemaProperty(ObjectNode propertiesNode, SerializerProvider provider) throws JsonMappingException; }

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>package com.fasterxml.jackson.databind.deser.std; import java.io.IOException; import com.fasterxml.jackson.core.*; import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.deser.BeanDeserializer; import com.fasterxml.jackson.databind.deser.SettableBeanProperty; import com.fasterxml.jackson.databind.util.NameTransformer; /** * Deserializer that builds on basic {@link BeanDeserializer} but * override some aspects like instance construction. */ public class ThrowableDeserializer extends BeanDeserializer { private static final long serialVersionUID = 1L; protected final static String PROP_NAME_MESSAGE = "message"; /* /************************************************************ /* Construction /************************************************************ */ public ThrowableDeserializer(BeanDeserializer baseDeserializer) { super(baseDeserializer); // need to disable this, since we do post-processing _vanillaProcessing = false; } /** * Alternative constructor used when creating "unwrapping" deserializers */ protected ThrowableDeserializer(BeanDeserializer src, NameTransformer unwrapper) { super(src, unwrapper); } @Override public JsonDeserializer<Object> unwrappingDeserializer(NameTransformer unwrapper) { if (getClass() != ThrowableDeserializer.class) { return this; } /* main thing really is to just enforce ignoring of unknown * properties; since there may be multiple unwrapped values * and properties for all may be interleaved... */ return new ThrowableDeserializer(this, unwrapper); } /* /************************************************************ /* Overridden methods /************************************************************ */ @Override public Object deserializeFromObject(JsonParser jp, DeserializationContext ctxt) throws IOException { // 30-Sep-2010, tatu: Need to allow use of @JsonCreator, so: if (_propertyBasedCreator != null) { // proper @JsonCreator return _deserializeUsingPropertyBased(jp, ctxt); } if (_delegateDeserializer != null) { return _valueInstantiator.createUsingDelegate(ctxt, _delegateDeserializer.deserialize(jp, ctxt)); } if (_beanType.isAbstract()) { // for good measure, check this too throw JsonMappingException.from(jp, "Can not instantiate abstract type "+_bean

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>Type +" (need to add/enable type information?)"); } boolean hasStringCreator = _valueInstantiator.canCreateFromString(); boolean hasDefaultCtor = _valueInstantiator.canCreateUsingDefault(); // and finally, verify we do have single-String arg constructor (if no @JsonCreator) if (!hasStringCreator && !hasDefaultCtor) { throw new JsonMappingException("Can not deserialize Throwable of type "+_beanType +" without having a default contructor, a single-String-arg constructor; or explicit @JsonCreator"); } Object throwable = null; Object[] pending = null; int pendingIx = 0; for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { String propName = jp.getCurrentName(); SettableBeanProperty prop = _beanProperties.find(propName); jp.nextToken(); // to point to field value if (prop != null) { // normal case if (throwable != null) { prop.deserializeAndSet(jp, ctxt, throwable); continue; } // nope; need to defer if (pending == null) { int len = _beanProperties.size(); pending = new Object[len + len]; } pending[pendingIx++] = prop; pending[pendingIx++] = prop.deserialize(jp, ctxt); continue; } // Maybe it's "message"? if (PROP_NAME_MESSAGE.equals(propName)) { if (hasStringCreator) { throwable = _valueInstantiator.createFromString(ctxt, jp.getText()); // any pending values? if (pending != null) { for (int i = 0, len = pendingIx; i < len; i += 2) { prop = (SettableBeanProperty)pending[i]; prop.set(throwable, pending[i+1]); } pending = null; } continue; } } /* As per [JACKSON-313], things marked as ignorable should not be * passed to any setter */ if (_ignorableProps != null && _ignorableProps.contains(propName)) { jp.skipChildren(); continue; } if (_anySetter != null) { _anySetter.deserializeAndSet(

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>package com.fasterxml.jackson.databind.node; import com.fasterxml.jackson.core.*; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.jsontype.TypeSerializer; import java.io.IOException; import java.math.BigDecimal; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; /** * Node that maps to JSON Object structures in JSON content. *<p> * Note: class was <code>final</code> temporarily for Jackson 2.2. */ public class ObjectNode extends ContainerNode<ObjectNode> { // Note: LinkedHashMap for backwards compatibility protected final Map<String, JsonNode> _children; public ObjectNode(JsonNodeFactory nc) { super(nc); _children = new LinkedHashMap<String, JsonNode>(); } /** * @since 2.4 */ public ObjectNode(JsonNodeFactory nc, Map<String, JsonNode> kids) { super(nc); _children = kids; } @Override protected JsonNode _at(JsonPointer ptr) { return get(ptr.getMatchingProperty()); } /* Question: should this delegate to `JsonNodeFactory`? It does not absolutely * have to, as long as sub-types override the method but... */ // note: co-variant for type safety @SuppressWarnings("unchecked") @Override public ObjectNode deepCopy() { ObjectNode ret = new ObjectNode(_nodeFactory); for (Map.Entry<String, JsonNode> entry: _children.entrySet()) ret._children.put(entry.getKey(), entry.getValue().deepCopy()); return ret; } /* /********************************************************** /* Implementation of core JsonNode API /********************************************************** */ @Override public JsonNodeType getNodeType() { return JsonNodeType.OBJECT; } @Override public JsonToken asToken() { return JsonToken.START_OBJECT; } @Override public int size() { return _children.size(); } @Override

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> public Iterator<JsonNode> elements() { return _children.values().iterator(); } @Override public JsonNode get(int index) { return null; } @Override public JsonNode get(String fieldName) { return _children.get(fieldName); } @Override public Iterator<String> fieldNames() { return _children.keySet().iterator(); } @Override public JsonNode path(int index) { return MissingNode.getInstance(); } @Override public JsonNode path(String fieldName) { JsonNode n = _children.get(fieldName); if (n != null) { return n; } return MissingNode.getInstance(); } /** * Method to use for accessing all fields (with both names * and values) of this JSON Object. */ @Override public Iterator<Map.Entry<String, JsonNode>> fields() { return _children.entrySet().iterator(); } @Override public ObjectNode with(String propertyName) { JsonNode n = _children.get(propertyName); if (n != null) { if (n instanceof ObjectNode) { return (ObjectNode) n; } throw new UnsupportedOperationException("Property '" + propertyName + "' has value that is not of type ObjectNode (but " + n .getClass().getName() + ")"); } ObjectNode result = objectNode(); _children.put(propertyName, result); return result; } @Override public ArrayNode withArray(String propertyName) { JsonNode n = _children.get(propertyName); if (n != null) { if (n instanceof ArrayNode) { return (ArrayNode) n; } throw new UnsupportedOperationException("Property '" + propertyName + "' has value that is not of type ArrayNode (but " + n .getClass().getName() + ")"); } ArrayNode result = arrayNode(); _children.put(propertyName, result); return result; } /* /********************************************************** /* Public API, finding value nodes /********************************************************** */ @Override public JsonNode findValue(String fieldName) { for (Map.Entry<String, JsonNode> entry : _children.entrySet()) { if (fieldName.equals(entry.getKey())) { return entry.getValue(); } JsonNode value = entry

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>(String fieldName, JsonNode value) { if (value == null) { value = nullNode(); } _children.put(fieldName, value); return this; } /** * Method for adding given properties to this object node, overriding * any existing values for those properties. * * @param properties Properties to add * * @return This node after adding/replacing property values (to allow chaining) * * @since 2.1 */ public JsonNode setAll(Map<String,? extends JsonNode> properties) { for (Map.Entry<String,? extends JsonNode> en : properties.entrySet()) { JsonNode n = en.getValue(); if (n == null) { n = nullNode(); } _children.put(en.getKey(), n); } return this; } /** * Method for adding all properties of the given Object, overriding * any existing values for those properties. * * @param other Object of which properties to add to this object * * @return This node after addition (to allow chaining) * * @since 2.1 */ public JsonNode setAll(ObjectNode other) { _children.putAll(other._children); return this; } /** * Method for replacing value of specific property with passed * value, and returning value (or null if none). * * @param fieldName Property of which value to replace * @param value Value to set property to, replacing old value if any * * @return Old value of the property; null if there was no such property * with value * * @since 2.1 */ public JsonNode replace(String fieldName, JsonNode value) { if (value == null) { // let's not store 'raw' nulls but nodes value = nullNode(); } return _children.put(fieldName, value); } /** * Method for removing field entry from this ObjectNode, and * returning instance after removal. * * @return This node after removing entry (if any) * * @since 2.1 */ public JsonNode without(String fieldName) { _children.remove(fieldName); return this; } /** * Method for

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> removing specified field properties out of * this ObjectNode. * * @param fieldNames Names of fields to remove * * @return This node after removing entries * * @since 2.1 */ public ObjectNode without(Collection<String> fieldNames) { _children.keySet().removeAll(fieldNames); return this; } /* /********************************************************** /* Extended ObjectNode API, mutators, generic /********************************************************** */ /** * Method that will set specified field, replacing old value, if any. * * @param value to set field to; if null, will be converted * to a {@link NullNode} first (to remove field entry, call * {@link #remove} instead) * * @return Old value of the field, if any; null if there was no * old value. * * @deprecated Since 2.4 use either {@link #set(String,JsonNode)} or {@link #replace(String,JsonNode)}, */ @Deprecated public JsonNode put(String fieldName, JsonNode value) { if (value == null) { // let's not store 'raw' nulls but nodes value = nullNode(); } return _children.put(fieldName, value); } /** * Method for removing field entry from this ObjectNode. * Will return value of the field, if such field existed; * null if not. * * @return Value of specified field, if it existed; null if not */ public JsonNode remove(String fieldName) { return _children.remove(fieldName); } /** * Method for removing specified field properties out of * this ObjectNode. * * @param fieldNames Names of fields to remove * * @return This node after removing entries */ public ObjectNode remove(Collection<String> fieldNames) { _children.keySet().removeAll(fieldNames); return this; } /** * Method for removing all field properties, such that this * ObjectNode will contain no properties after call. * * @return This node after removing all entries */ @Override public ObjectNode removeAll() { _children.clear(); return this; } /** * Method for adding given properties

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>> instance. * * @return Newly constructed ArrayNode (NOT the old value, * which could be of any type) */ public ArrayNode putArray(String fieldName) { ArrayNode n = arrayNode(); _put(fieldName, n); return n; } /** * Method that will construct an ObjectNode and add it as a * field of this ObjectNode, replacing old value, if any. *<p> * <b>NOTE</b>: Unlike all <b>put(...)</b> methods, return value * is <b>NOT</b> this <code>ObjectNode</code>, but the * <b>newly created</b> <code>ObjectNode</code> instance. * * @return Newly constructed ObjectNode (NOT the old value, * which could be of any type) */ public ObjectNode putObject(String fieldName) { ObjectNode n = objectNode(); _put(fieldName, n); return n; } /** * @return This node (to allow chaining) */ public ObjectNode putPOJO(String fieldName, Object pojo) { return _put(fieldName, pojoNode(pojo)); } /** * @return This node (to allow chaining) */ public ObjectNode putNull(String fieldName) { _children.put(fieldName, nullNode()); return this; } /** * Method for setting value of a field to specified numeric value. * * @return This node (to allow chaining) */ public ObjectNode put(String fieldName, short v) { return _put(fieldName, numberNode(v)); } /** * Alternative method that we need to avoid bumping into NPE issues * with auto-unboxing. * * @return This node (to allow chaining) */ public ObjectNode put(String fieldName, Short v) { return _put(fieldName, (v == null) ? nullNode() : numberNode(v.shortValue())); } /** * Method for setting value of a field to specified numeric value. * The underlying {@link JsonNode} that will be added is constructed * using {@link JsonNodeFactory#numberNode(int)}, and may be

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> * "smaller" (like {@link ShortNode}) in cases where value fits within * range of a smaller integral numeric value. * * @return This node (to allow chaining) */ public ObjectNode put(String fieldName, int v) { return _put(fieldName, numberNode(v)); } /** * Alternative method that we need to avoid bumping into NPE issues * with auto-unboxing. * * @return This node (to allow chaining) */ public ObjectNode put(String fieldName, Integer v) { return _put(fieldName, (v == null) ? nullNode() : numberNode(v.intValue())); } /** * Method for setting value of a field to specified numeric value. * The underlying {@link JsonNode} that will be added is constructed * using {@link JsonNodeFactory#numberNode(long)}, and may be * "smaller" (like {@link IntNode}) in cases where value fits within * range of a smaller integral numeric value. * * @return This node (to allow chaining) */ public ObjectNode put(String fieldName, long v) { return _put(fieldName, numberNode(v)); } /** * Method for setting value of a field to specified numeric value. * The underlying {@link JsonNode} that will be added is constructed * using {@link JsonNodeFactory#numberNode(Long)}, and may be * "smaller" (like {@link IntNode}) in cases where value fits within * range of a smaller integral numeric value. * <p> * Note that this is alternative to {@link #put(String, long)} needed to avoid * bumping into NPE issues with auto-unboxing. * * @return This node (to allow chaining) */ public ObjectNode put(String fieldName, Long v) { return _put(fieldName, (v == null) ? nullNode() : numberNode(v.longValue())); } /** * Method for setting value of a field to specified numeric value. * * @return This node (to allow chaining) */ public ObjectNode put(String fieldName, float v) { return _put(fieldName, numberNode(v)); } /** * Alternative method that

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> we need to avoid bumping into NPE issues * with auto-unboxing. * * @return This node (to allow chaining) */ public ObjectNode put(String fieldName, Float v) { return _put(fieldName, (v == null) ? nullNode() : numberNode(v.floatValue())); } /** * Method for setting value of a field to specified numeric value. * * @return This node (to allow chaining) */ public ObjectNode put(String fieldName, double v) { return _put(fieldName, numberNode(v)); } /** * Alternative method that we need to avoid bumping into NPE issues * with auto-unboxing. * * @return This node (to allow chaining) */ public ObjectNode put(String fieldName, Double v) { return _put(fieldName, (v == null) ? nullNode() : numberNode(v.doubleValue())); } /** * Method for setting value of a field to specified numeric value. * * @return This node (to allow chaining) */ public ObjectNode put(String fieldName, BigDecimal v) { return _put(fieldName, (v == null) ? nullNode() : numberNode(v)); } /** * Method for setting value of a field to specified String value. * * @return This node (to allow chaining) */ public ObjectNode put(String fieldName, String v) { return _put(fieldName, (v == null) ? nullNode() : textNode(v)); } /** * Method for setting value of a field to specified String value. * * @return This node (to allow chaining) */ public ObjectNode put(String fieldName, boolean v) { return _put(fieldName, booleanNode(v)); } /** * Alternative method that we need to avoid bumping into NPE issues * with auto-unboxing. * * @return This node (to allow chaining) */ public ObjectNode put(String fieldName, Boolean v) { return _put(fieldName, (v == null) ? nullNode() : booleanNode(v.booleanValue())); } /** * Method for setting value of a field to specified binary value

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> * * @return This node (to allow chaining) */ public ObjectNode put(String fieldName, byte[] v) { return _put(fieldName, (v == null) ? nullNode() : binaryNode(v)); } /* /********************************************************** /* Standard methods /********************************************************** */ @Override public boolean equals(Object o) { if (o == this) return true; if (o == null) return false; if (o instanceof ObjectNode) { return _childrenEqual((ObjectNode) o); } return false; } /** * @since 2.3 */ protected boolean _childrenEqual(ObjectNode other) { return _children.equals(other._children); } @Override public int hashCode() { return _children.hashCode(); } @Override public String toString() { StringBuilder sb = new StringBuilder(32 + (size() << 4)); sb.append("{"); int count = 0; for (Map.Entry<String, JsonNode> en : _children.entrySet()) { if (count > 0) { sb.append(","); } ++count; TextNode.appendQuoted(sb, en.getKey()); sb.append(':'); sb.append(en.getValue().toString()); } sb.append("}"); return sb.toString(); } /* /********************************************************** /* Internal methods (overridable) /********************************************************** */ protected ObjectNode _put(String fieldName, JsonNode value) { _children.put(fieldName, value); return this; } }

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS>] = value; long typeCode = (long) rawTokenType; if (index > 0) { typeCode <<= (index << 2); } _tokenTypes |= typeCode; assignNativeIds(index, objectId, typeId); } private final void assignNativeIds(int index, Object objectId, Object typeId) { if (_nativeIds == null) { _nativeIds = new TreeMap<Integer,Object>(); } if (objectId != null) { _nativeIds.put(_objectIdIndex(index), objectId); } if (typeId != null) { _nativeIds.put(_typeIdIndex(index), typeId); } } /** * @since 2.3 */ public Object findObjectId(int index) { return (_nativeIds == null) ? null : _nativeIds.get(_objectIdIndex(index)); } /** * @since 2.3 */ public Object findTypeId(int index) { return (_nativeIds == null) ? null : _nativeIds.get(_typeIdIndex(index)); } private final int _typeIdIndex(int i) { return i+i; } private final int _objectIdIndex(int i) { return i+i+1; } } }

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> || (et != null && et.isFinal()); _valueTypeSerializer = vts; _property = property; _elementSerializer = elementSerializer; _dynamicSerializers = PropertySerializerMap.emptyForProperties(); } @SuppressWarnings("unchecked") protected AsArraySerializerBase(AsArraySerializerBase<?> src, BeanProperty property, TypeSerializer vts, JsonSerializer<?> elementSerializer) { super(src); _elementType = src._elementType; _staticTyping = src._staticTyping; _valueTypeSerializer = vts; _property = property; _elementSerializer = (JsonSerializer<Object>) elementSerializer; _dynamicSerializers = src._dynamicSerializers; } public abstract AsArraySerializerBase<T> withResolved(BeanProperty property, TypeSerializer vts, JsonSerializer<?> elementSerializer); /* /********************************************************** /* Post-processing /********************************************************** */ /** * This method is needed to resolve contextual annotations like * per-property overrides, as well as do recursive call * to <code>createContextual</code> of content serializer, if * known statically. */ @Override public JsonSerializer<?> createContextual(SerializerProvider provider, BeanProperty property) throws JsonMappingException { TypeSerializer typeSer = _valueTypeSerializer; if (typeSer != null) { typeSer = typeSer.forProperty(property); } /* 29-Sep-2012, tatu: Actually, we need to do much more contextual * checking here since we finally know for sure the property, * and it may have overrides */ JsonSerializer<?> ser = null; // First: if we have a property, may have property-annotation overrides if (property != null) { AnnotatedMember m = property.getMember(); if (m != null) { Object serDef = provider.getAnnotationIntrospector().findContentSerializer(m); if (serDef != null) { ser = provider.serializerInstance(m, serDef); } } } if (ser == null) { ser = _elementSerializer; } // 18-Feb-2013, tatu: May have a content converter: ser = findConvertingContentSerializer(provider, property, ser);

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> and probably just won't work typeSer.writeTypePrefixForArray(value, gen); // [databind#631]: Assign current value, to be accessible by custom serializers gen.setCurrentValue(value); serializeContents(value, gen, provider); typeSer.writeTypeSuffixForArray(value, gen); } protected abstract void serializeContents(T value, JsonGenerator gen, SerializerProvider provider) throws IOException; @SuppressWarnings("deprecation") @Override public JsonNode getSchema(SerializerProvider provider, Type typeHint) throws JsonMappingException { ObjectNode o = createSchemaNode("array", true); JavaType contentType = _elementType; if (contentType != null) { JsonNode schemaNode = null; // 15-Oct-2010, tatu: We can't serialize plain Object.class; but what should it produce here? Untyped? if (contentType.getRawClass() != Object.class) { JsonSerializer<Object> ser = provider.findValueSerializer(contentType, _property); if (ser instanceof SchemaAware) { schemaNode = ((SchemaAware) ser).getSchema(provider, null); } } if (schemaNode == null) { schemaNode = com.fasterxml.jackson.databind.jsonschema.JsonSchema.getDefaultSchemaNode(); } o.put("items", schemaNode); } return o; } @Override public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) throws JsonMappingException { JsonArrayFormatVisitor arrayVisitor = (visitor == null) ? null : visitor.expectArrayFormat(typeHint); if (arrayVisitor != null) { /* 01-Sep-2014, tatu: Earlier was trying to make use of 'typeHint' for some * reason, causing NPE (as per https://github.com/FasterXML/jackson-module-jsonSchema/issues/34) * if coupled with `@JsonValue`. But I can't see much benefit of trying to rely * on TypeHint here so code is simplified like so: */ JsonSerializer<?> valueSer = _elementSerializer; if (valueSer == null) { valueSer = visitor.getProvider().findValueSerializer(_elementType, _property);

JacksonDatabind, 14

<FILEB>
<CHANGES>
JsonDeserializer<Object> deser = _findTreeDeserializer(ctxt);
<CHANGEE>
<CHANGES>
protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt)
throws JsonMappingException
{
JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE);
if (deser == null) {
<CHANGEE>
<CHANGES>
deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE);
if (deser == null) { // can this happen?
throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE);
}
_rootDeserializers.put(JSON_NODE_TYPE, deser);
}
return deser;
}
<CHANGEE>
<FILEE>
<FILEB> } protected JsonNode _bindAndCloseAsTree(JsonParser jp) throws IOException { try { return _bindAsTree(jp); } finally { try { jp.close(); } catch (IOException ioe) { } } } protected JsonNode _bindAsTree(JsonParser jp) throws IOException { JsonNode result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL || t == JsonToken.END_ARRAY || t == JsonToken.END_OBJECT) { result = NullNode.instance; } else { DeserializationContext ctxt = createDeserializationContext(jp, _config); <CHANGES> JsonDeserializer<Object> deser = _findRootDeserializer(ctxt, JSON_NODE_TYPE); <CHANGEE> if (_unwrapRoot) { result = (JsonNode) _unwrapAndDeserialize(jp, ctxt, JSON_NODE_TYPE, deser); } else { result = (JsonNode) deser.deserialize(jp, ctxt); } } // Need to consume the token too jp.clearCurrentToken(); return result; } /** * @since 2.1 throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; } /** * @since 2.6 */ <CHANGES> <CHANGEE> // Nope: need to ask provider to resolve it <CHANGES> <CHANGEE> /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(DeserializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null;<SCANS> } arrayVisitor.itemsFormat(valueSer, _elementType); } } protected final JsonSerializer<Object> _findAndAddDynamic(PropertySerializerMap map, Class<?> type, SerializerProvider provider) throws JsonMappingException { PropertySerializerMap.SerializerAndMapResult result = map.findAndAddSecondarySerializer(type, provider, _property); // did we get a new map of serializers? If so, start using it if (map != result.map) { _dynamicSerializers = result.map; } return result.serializer; } protected final JsonSerializer<Object> _findAndAddDynamic(PropertySerializerMap map, JavaType type, SerializerProvider provider) throws JsonMappingException { PropertySerializerMap.SerializerAndMapResult result = map.findAndAddSecondarySerializer(type, provider, _property); if (map != result.map) { _dynamicSerializers = result.map; } return result.serializer; } }